In this tutorial we will learn how to create and Setup Gridview Controls. Gridviews can be helpful when listing information out of SQL Databases. The difference between the Gridview and the Repeater is the formatting, Gridviews generally look like Tables while Repeaters have a more free form style.

Step 1. Setting up the Project and Creating the Gridview

1. Create a new Project in Visual Web Developer
2. Create a new Web From named “Default.aspx”
3. Create a new SQL Database and name it “Gridview.mdf”
4. Inside that Database create a Table called “Gridview” with the Columns ID(Primary Key, Identity), and Name(varchar(50))
5. Fill the Table out with some sample Data by right clicking it and selecting Show Table Data
6. Now go onto the form and drag an SQL data source object onto the form
7. Setup the SQL data source to connect to the Database and Table we just created by clicking on the Smart Tag and selecting Configure DataSource

Step 2. Setting up the Gridview

1. Drag a Gridview Control from the Data Section of the Toolbar onto the Form
2. Click on the Smart Tag and select the Data Source we just created (“SqlDataSource1″ for me)
3. Now you have linked the Data Source to the Gridview you can now run the project and view the Gridview object in action.


In this tutorial we learned how to use the Gridview control in ASP.NET. The Gridview Control can be very useful for sorting information out of an SQL database into a table. The Gridview is also a simple more styled alternative to the Repeater Control information (here). Take your pick on which Control suits your website.

Download Source Files