.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> LINQ >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Bind Gridview using LINQ

Posted By:Athira Sreejith       Posted Date: December 31, 2008    Points: 10    Category: LINQ    URL: http://www.dotnetspark.com  
 

Bind Gridview using LINQ

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
BindGrid();
}

private void BindGrid()
{
VetcareDataContext vetcare = new VetcareDataContext();
var Employee = from e in vetcare.Pay_Employees orderby e.Name select e;
gvEmployee.DataSource = Employee;
gvEmployee.DataBind();
}
protected void gvEmployee_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvEmployee.PageIndex = e.NewPageIndex;
BindGrid();
}
}

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend