This is the sample Griv View

Here I am using an xml file to get the data required for filling the grid. This is how the data will look in the xml file
<Courses> <Course> <Number>23</Number> <Name>Science</Name> <StartDate>29/02/2010</StartDate> </Course> <Course> <Number>24</Number> <Name>Social</Name> <StartDate>29/01/2010</StartDate> </Course> </Courses> Now bind this data with the grid view in page_load as follows DataSet ds = new DataSet(); ds.ReadXml(Request.PhysicalApplicationPath + "XMLFile.xml");

Now set grid view Allow Paging property to true and whenever you click on the page number the event gridView_Changing event should be handled.
Write the below code in this event and bind the gridview again grvCourse.PageIndex = e.NewPageIndex; PopulateGrid((DataTable)Session["table"]); This is the content in the second page

-2-

Set Allow Sorting property to true of the gridview and give sortexpression values for the fields whatever you want to sort. For other fields don’t specify any sort expression.

Now when you click on the header to sort the data gridview_sorting event should be handled. When you try to sort the course name in the above grid this is what you see

Download the entire project source code from the below link

-3-

http://docs.google.com/leaf? id=0B8hoTwnI_pgYOGQwZWY4MDktNjE0My00OTUwLWE4NjQtMWU2ZDM5ZDhm NGU3&hl=en

Sign up to vote on this title
UsefulNot useful