Tutorial RSS
 
DB Tutorials Server Intellect Cloud Hosting
Navigator: Home - Display - Binding Data Using the GridView Control

Binding Data Using the GridView Control

In this tutorial we will cover creating a GridView control and binding it to a pre-existing database table.

Binding Data Using the GridView Control

Download the GridView control Project Source

 

In this tutorial we will cover creating a GridView control and binding it to a pre-existing database table.

We used over 10 web hosting companies before we found Server Intellect. Our new cloud server was set up in less than 24 hours. We were able to confirm our order over the phone. They responded to our inquiries within an hour. Server Intellect's customer support and assistance are the best we've ever experienced.

The GridView control lets us work with and manipulate data from the SQL database by using and configuring a simple control.  In order to follow this tutorial you must have an SQL database installed on visual studio in order to bind the control to it. You can download and use the sample database tutorial in order to follow along as well.

1. Open the website project in visual studio and right click on the name of the website in the solution explorer.

2. Select Add New Item.

3. When the Installed Templates list opens, select a Web Form then name it and click Add.

-If you are planning on using this control in an existing project you can skip the previous steps.

4. Switch to design view.

5. In the Toolbox under the data menu, click and drag a GridView control onto the page.

6. In the GridView Tasks menu select the data source you want to bind to from the drop down menu (If you are using the sample database provided, the data source will be the default SqlDataSource1). See the image below.

 

                      

 

Yes, it is possible to find a good web host. Sometimes it takes a while. After trying several, we went with Server Intellect and have been very happy. They are the most professional, customer service friendly and technically knowledgeable host we've found so far.

7. When the Data Connection Wizard opens, Select ConnectionString from the dropdown menu and click next.

8. When the next window opens (Configure the Select Statement) make sure the Asterisk on the top of the checklist box menu is selected (this selects all items in the list). See image below.

-The columns list lets you select which items from the database table you want to incorporate into the control.

 

                        

 

9. In the same window click the advanced button on the right side of the menu. See image below.

-The Generation options menu lets you create statements on your control that let the user insert, edit and delete content in the SQL database.

 

                      

 

10. Make sure the top box is checked and the bottom box is unchecked and then click Ok.

11. Select next in the Configure the Select Statement menu.

12. The last menu in the wizard to appear is the Test Query menu. You can test your SQL connection by clicking on the Test Query button.  The table data you are binding the control to will appear in the preview window if the connection is successful. See image below.

 

                       

 

 

13. Click Finish.

14. Select the GridView Tasks menu again and notice that now there are some additional selections.

-These selections let you customize the control to enable paging, inserting, editing, and deleting of the database information.

15. Save your work then run or debug the application.

-You now have a functional GridView control you can use to manage the data from the SQL database on your webpages.

Server Intellect assists companies of all sizes with their hosting needs by offering fully configured server solutions coupled with proactive server management services. Server Intellect specializes in providing complete internet-ready server solutions backed by their expert 24/365 proactive support team.