In-Depth look at the GridView Control
We all enjoyed the datalist and the datagrid controls in Asp.net 1.1. There were thousands of operations that we can perform using datagrid and datalist control. Asp.net 2.0 ships with another data bound templated control which is called Grid View. Grid View has made everything easier for developers. The main changes that I have seen in Asp.net 2.0 is that we don’t require a lot of code to achieve tasks but most of the functionality is already provided and built in the control. In this article we will see the GridView control in action and we will see what type of operations we can perform using this control and how this control is better than the classic datagrid control.
…
Using the GridView Control: If you read my previous articles on DataGrid control you might have noticed that we need to write quite a bit of code to enable paging, sorting and selecting an item from the datagrid. Using the gridview control I did not even write a single line and got all the three things i.e., paging, sorting and selection for granted. Here is how I did it in less than 2 minutes: (Sample1.aspx)
1) Drag a SqlDataSource control on the form and configure it using the wizard.
2) Once you got the SqlDataSource control set up you are ready to drag the grid on the form.
3) Simply drag the gridview control on the form and set its data source to the SqlDataSource Object.
…
Now in the Small menu on the right hand side you can see that I have set the datasource to the myDataSource where myDataSource is simply the SqlDataSource. I hope you can see the Enable paging, Enable sorting and Enable selection checkboxes. If you like you can check them all and that’s it you will get a grid with all the three functionalities cool right ? Now if you run the page you will see something like this depending on which table you have used to populate the SqlDataSource control.
…
Website: dotnetsparkles.files.wordpress.com | Filesize: 915kb
No of Page(s): 11
Click here to download In-Depth look at the GridView Control.
Related Tutorial
Tags: .NET, graphical user interface, gridview
Comments
Leave a Reply