Welcome Guest
Tanvtech logo
Tanvtech logo
 
Here we are going to use the LINQ and bind it to the GridView control Step1:Drag a Grid View to you webpage

Click auto Format and select nice format, set the width of the Grid View.
Step 2: Connect to the database using LINQ
Add new Item to your project by right clicking on the project

Select LINQ to SQL Classes to the project and give a name to the class like TanvtechDataClass

Step 3: Click View and select server Explorer

Click Connect to the database

Select server name you want to connect, and also select the database from the database drop down list to connect.

Select the table from the table list

Drag the table or the store procedure you want to use to the Database Class you added

And copy the code listed below to the page load event.
protected void Page_Load(object sender, EventArgs e)
{
TanvtechDataClassesDataContext db = new TanvtechDataClassesDataContext() TanvtechGridView.DataSource = db.StudentInfos.ToList(); TanvtechGridView.DataBind();
}
Or you can try this.

Run the application and you will see

 
© Tanvtech. All Rights Reserved.