Exforsys.com
 
Home Tutorials ASP.NET 2.0
 

ASP.NET Displaying Master-Detail Data on the Same Page

 

ASP.NET Displaying Master-Detail Data on the Same Page - Page 2

Page 2 of 2



To configure a query to display related records

1. Press ENTER to make space underneath the SqlDataSource1 control.


2. From the Data group of the Toolbox, drag a DetailsView control onto the page.


3. Configure it to use a second data source control using the following steps:


.......a. From the Choose Data Source list, select < New Data Source >.


.......b. Select Database.


.......c. Click OK.


.......d. In the Choose a data connection list, click the connection you created and stored
.......earlier in the walkthrough.


.......e. Click Next.


.......f. From the Name list under Table or View Options, select StudentMaster.


.......g. In the Columns box, check StudentId, StudentName and CourseId.


.......h. Click WHERE.


.......The Add WHERE Clause dialog box is displayed:


.......i. From the Column list, select CourseId


.......j. From the Operator list, select =.


.......k. From the Source list, select Control.


.......Under Parameter Properties, in the Control ID list, select GridView1. The query for the
.......second grid will get its parameter value from the selection in the first grid.


.......l. Click Add and then click OK to close the Add WHERE Clause dialog box.


.......m. Click Next.


.......n. In the Preview page, click Test Query.


.......The wizard displays a dialog box that prompts you for a value to use in the WHERE clause.


.......o. Type 22 in the box and click OK.


4. The Student records for CourseId 22 are displayed.



5. Click Finish.


6. In the Common DetailsView Tasks menu, check Enable Paging.



7. This will allow the user scroll through individual Student records.


8. Optionally, in the Properties window, open the PagerSettings node and select a different Mode value.




9. By default, you page through records by clicking a page number, but the user can select options to use next and previous links.


10. The page can now be tested.


To test the page

1. Press CTRL+F5 to run the page.


2. In the grid, select a category.


3. The DetailsView control displays a Student record associated with that CourseId.


4. Use the pager links in the DetailsView control to navigate to other student records for the same courseId.


5. In the grid, select a different CourseId.



6. Review the Student records for that CourseId in the DetailsView control.




First Page: ASP.NET Displaying Master-Detail Data on the Same Page


Read Next: Displaying Master-Detail Data on Separate Pages in ASP.NET 2.0



 

 

Comments


danacton said:

  Nice tutorial, i just went thru it and it worked first time
August 19, 2006, 10:31 pm

Bill said:

  Happiness is a to the point, plain english tutorial... that WORKS!

Thanks man. I've added insert/edit and delete to my detailsview so now I have to go figure out how to automagically update the gridview ;)

THANKS!
December 17, 2008, 12:17 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape