GridView
Displaying tabular data is most crucial work in software development.ASP.NET provides a number of tools or controls to fulfill this purpose. GridView control is one of them. It is the supergun of .net framework. It is most rich, featured and versatile control. It is used to display, update, delete and sort data from many types of data sources such as database, Xml files and business objects.
Working with GridView control
To use a GridView control, a DataSource control has to be attached to the GridView control. The property DataSourceID of the GridView control binds the GridView control to the DataSource control.
Steps to follow:
Before working with Gridview we require to create table with the help of any database vendor like SQL Server or Oracle or MSAccess or any other vendors.Here we are using SQL Server 2005 and created table Intro
1. Drag a GridView control from the toolbox pane to the ASP page.In design view click on GridView control ,
GridView task box will display.
2. Click on
New data source from dropdown list, Choose a
Data Source Configuration Wizard window will come.
3. Select any data source. We select Sql data source and click on button OK.
4. Configure Data Source window will come. Click on button
New Connection.
5. Choose
Configure Data Source window will come. Select
Microsoft SQL Server. Two options will populate in Data Provider dropdown list. Select
.NET Framework Data Provider for SQL Server and click on button
Continue.
6.
Add Connection window will come. Enter Server name. For this SQL Server should install in our system.
7. When we will enter server name, Select or enter a database name dropdown list will be enabled and database names would populated in dropdown list. Select proper database and click on button
Test Connection.
8. Test connection succeeded message box will populate and then click on button OK in message box.
9. Click on button OK in
Add Connection window. Flow will come again on
Configure Data Source window.
10. Click on button
Next and again
Next. We can see the columns of the table Intro.
11. Click on button
Next and we will see Test Query option in
Configure Data Source window where there is a button
Test Query. On clicking on button
Test Query we will see the data contained in Intro table. Click on button
Finish.
12. We can see the columns mentioned in the table
Intro.
13. Run this program by pressing F5 and we see the data is retrieved from the table Intro in Grid form in web page.