Wednesday, June 8, 2011

introduction to gridview

In this post i'll discuss about using asp.net grid view

first of all how to bind a grid view

 DataSet ds = read_from_xml();
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        GridView1.DataSource = ds;
                        GridView1.DataBind();
                    }
                }
here read_from_xml is a funtion which reads a xml file , parse it tinto a datatable and return into dataset 

DataSet is a set of data tables

Above is the code for cs which is used to bind the dataset with gridview.

now go to gridview and right click on it
go to properties
set autogeneratecolumns = true;
press F5 and see the results.

The page will show the content of the grid


No comments:

Post a Comment