ASP.NET Simple GridView
The GridView control offers a multitude of integrated functionalities, empowering users to effortlessly sort, update, delete, select, and page through items within the control. To establish a connection between the GridView control and a data source control, you can utilize the binding capabilities.
By setting the DataSourceID property of the GridView control to the ID value of the desired data source control, you can seamlessly bind the data source to the GridView control, thereby enabling efficient data manipulation. This streamlined approach facilitates the synchronization of data between the GridView and the data source, ensuring a smooth and coherent user experience.
In this article I have used Microsoft's Pubs database for sample data. You can download it free from the following link.Download
To begin generating a GridView in your ASP file, it is essential to create a ConnectionString within your web.config file. To accomplish this, follow these steps:
- Locate the web.config file in your project's directory within Visual Studio.
- Double-click on the web.config file to open it.
- Within the web.config file, identify the appropriate section to add the ConnectionString code.
After create the connectionstring in the web.config file, you should call the connectionstring in your asp page and issue the select command.
When you run this asp.net application , your output look likes the following image.
The following is the full asp source code for selecting au_lname,phone,address,city from the authors table in the Pubs database.
Asp.net gridview example