Introducing ASP.NET 2.0: GridView Control - Create the Database
(Page 2 of 5 )
Create a Microsoft Access database and the required table under it. Be sure to add some data to the table and move the database to the App_Data directory of the project folder.

Figure 3
Your next step is to configure the AccessDataSource control appropriately. For this purpose, select the Configure Data Source item from the balloon tip as shown in the above screenshot. You will be presented with a series of wizards as shown in Figures 4 and 5.

Figure 4
You have to manually type in the path of your MS Access database. I found that the Browse feature has not yet been fully implemented. Select the Next button to continue.

Figure 5
You must select the field names from the above wizard. As soon as you select the required columns, the select statement will be updated accordingly.

Figure 6
Initially, the required data will not appear as shown in the above screenshot. You have to click the Test Query button to complete this step. Visual Studio 2005 will display the data provided your database connection is properly set up. You will be returned to the Design View after this step.
Select the GridView control and set the DataSourceID property to AccessDataSource1. You will have to copy and paste the control name as the IDE will not automatically populate the same. Also set the DataMember property to DefaultView.
Finally, set the DataKeyNames property by clicking the ellipse. You will have to add the required field names from the left side to the right side list box (See Figure 7).

Figure 7
Next: Save and Run >>
More ASP.NET Articles
More By Anand Narayanaswamy