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.
Download Database
In this article I have used Microsoft's Pubs database for sample data. You can download it free from the following link.
DownloadTo 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.
Web.Config File
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
Default.aspx
- Sorting , Paging and AutoGenerateColumns
- ASP.NET GridView Editing
- ASP.NET GridView Delete
- DropDownList in GridView
- Create Gridview at runtime
- Asp.Net Gridview - Add, Edit and delete
- Gridview export to Excel
- Gridview export to CSV
- Asp.Net GridView summary on Footer
- Subtotal row in Gridview
- SubTotal and GrandTotal in GridView
- Create Gridview without database
- GridView from Stored Procedure
- How to create Gridview Popup Form
- How to create a Blank row in gridview
- Nested GridView in ASP.NET
- Freeze Gridview Header row, Scroll in GridView
- Auto Generate Row Number in GridView
- Image between GridView rows
- How to select a row in gridview
- Checkbox in ASP.NET GridView Control