I am continuing to
write the post on Linq. Here I have explained
how to perform crude operation
using Linq To Sql using c#.
If you don’t have Sql
Server Express then you can download from Here.
Launch Visual studio and open new web site . After this
right click on project application -> add new items -> select linq to sql
file -> named it whatever you want
-> click ok.
Drag and drop gridview on Design page.
Code Behind Default.aspx page:-
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Web;
using
System.Web.UI;
using
System.Web.UI.WebControls;
public partial class linq : System.Web.UI.Page
{
protected
void Page_Load(object
sender, EventArgs e)
{
NorthwindDataContext
nwdc = new NorthwindDataContext();
var emp = from myemp in nwdc.Employees
select myemp;
GridView1.DataSource =
emp;
GridView1.DataBind();
}
}
Press F5 and see the result. In next post I will add new thing about linq.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.