Working with DataGrids
(Page 1 of 5 )
This article presents a simple data display with DataGrid, shows how to add paging to the DataGrid, and how to make the DataGrid editable. Learn how to reduce the data by providing filters so users do not get more data than they need. Also covered is how to edit the DataGrid by adding DataBound columns or using template columns.
Feel free to download the support files for this article here.
When publishing a list of records in a web page, we need to do a lot of work in the Classic ASP. But with ASP.NET a developer need not worry much except for setting some properties and adding a little code. In classic ASP we have no option of grids, but we have to write code for creating Table and creating Page Numbers, etc. Working with DataGrid is quite simple when compared to other listing web controls. We can place a grid (Drag and Drop) and bind to a DataSource object to simply presents all records. The DataGrid in Web controls accepts wide range of DataSource objects. As long as the object implements System.Collections.IEnumerabale interface, it can be assigned as a DataSource for the DataGrid. The objects, for example, DataView, ArrayList, HashTable can be used as DataSource in web pages.
We can use XML or a database as a source for the data in the above said objects. For keeping common tasks in the view, I am going to present Database related code in this article. And one more point in the coding is, I am presenting the code which I wrote in the plain text editor so that users who use editors like UltraEdit and TextPad or NotePad may feel easy about understanding the coding. Those who use Visual Studio may not find much difficulty to use “code behind”.
I would like to present a simple data display with DataGrid in the beginning, and later on show how to add paging to the DataGrid, and finally, how to make our DataGrid editable. This may look complicated, but it's nothing but setting properties of the DataGrid most of the time and adding a little bit of code.
Next: A Simple Data Display >>
More ASP.NET Articles
More By JB Reddy