October 28, 2016
Hot Topics:

Building an ASP.NET 2.0 Master/Detail Application With DB2

  • October 13, 2006
  • By Anil Mahadev
  • Send Email »
  • More Articles »

Building the Application

Launch Visual Studio 2005, and then create a new Web site. Choose either C# or VB. Next, switch to design view, and then drag and drop a GridView Control and a Details View Control onto the Web form. Your application should now look like the one shown in Figure 1.

Click here for a larger image.

Figure 1: Web Form of Your Demo Master/Detail Application

Next, you configure the data source for your Grid View and Details View. Click on your Grid View Control and under Data Source choose New Data Source. Select Database and name it MasterDetail. Click OK.

Configuring the Details View

You now will see a dialog in which you need to specify an existing connection to a DB2 database. Click next and name this connection MasterDetailconString. Click Next. (Note: The DB2 Connection Wizard is being replaced and added to the Server Explorer to help maintain consistency when connecting to a variety of databases.) Now you will be asked to choose the table from DB2. Select DEPT table and click on the asterisk (*) checkbox to display all records. Finally, click Finish.

Configuring the Grid View

Follow the same steps for configuring the Grid View, except when you come to the screen where you chose DEPT as your table, click on the WHERE button instead. You need to modify your SQL statement with the following options in order to display the appropriate employee that belongs to a particular department:

  • Column: DEPTNO
  • Operator: =
  • Source: Control (This enables you to choose GridView1 as your source control for retrieving the appropriate employee information.)
  • Control ID: GridView1, and then click the Add button to complete the SQL query expression.

Figure 2 shows the WHERE clause with all the correct selections.

Click here for a larger image.

Figure 2: WHERE Clause With All the Correct Selections

Click OK and Finish, and your Grid View will be ready to go. You may want to auto-format it as well as your Details View for a better presentation.

You now have both your views configured, and you are ready to run the application. Your final application will look like the one shown in Figure 3.

Click here for a larger image.

Figure 3: Your Final Demo Master/Detail Application

Run the application by pressing F5. You should be able to view the final application as shown in the browser in Figure 4.

Click here for a larger image.

Figure 4: Browser View of Your Final Demo Master/Detail Application

Now wasn't it easy to work with DB2 using ASP.NET 2.0?

About the Author

Anil Mahadev is a DB2 enthusiast and DB2 India User Group Lead Logo Architect. Send him your feedback and comments at anilm001@gmail.com.

Page 2 of 2

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel