About Me

My photo
Hello, I'm a technology geek looking to upgrade my programming skills. These are some of the things I'm learning along my journey.

Tuesday, June 26, 2012

Introduction to the GridView Control in ASP.NET

Create a new web site in Visual Studio. Create a new database in Visual Studio. Right click on the web site name in the “Solution Explorer” and select “Add New Item...”. Select “Web Form” and click “Add”.




Make sure the web form that you just created is selected and is in “Design” view. Select the “Toolbox” on the left and drag a new “GridView”control from the “data section” on the the new web form.



Select the arrow on the right of the GridView control and select “New Datasource” in the dropdown menu by “Choose Datasource... “.



Choose “SQL Database” and click “OK”.



Choose the name of the database you created from the dropdown menu and click “Next”.



Make sure “Yes” is checked in the check box and a connection string name has been filled in and click “Next”.



Accept the defaults and click “Next”.


Click “Test Query” to see if the query is successful and then click “Finished”.



Press F5 to start the debugging session to see if the GridView shows in the browser with the data from your database.


No comments:

Post a Comment