Last post Jun 13, 2011 09:58 PM by Decker Dong - MSFT
Jun 11, 2011 08:18 AM|majdantonio|LINK
I have two tables:
1. Products, with the fileds:
ProductID, ProductName, ProductDetails, PhotoID
2. Photos with the fields:
PhotoID, ProductID, PhotoPath
Now I'm trying to insert a new product without the PhotoID and when it is done a hyperlink appears to go to anther page to add photos to these product, but I couldn't do that in a right way.
PLease can anyone help me with full code about this.
Thank you so much in advance
Jun 11, 2011 11:30 AM|scngan|LINK
my 2 sen,
your first sql insert query should leave the photoID value with some temp value.
then, when the link redirect to the next page, you can use the Request Query String format ( http://msdn.microsoft.com/en-us/library/ms524784(v=vs.90).aspx) to retain the ProductID
so that when in the insert photo page, you still keep a copy of the product id...
Jun 13, 2011 09:58 PM|Decker Dong - MSFT|LINK
Here're simple steps that you can take from——（For more you can see：http://www.exforsys.com/tutorials/asp.net-2.0/displaying-master-detail-data-on-separate-pages-in-asp.net-2.0.html)
1. Add a new page to the Web site and name it MasterCourses.aspx.
2. Switch to Design view.
3. Type Courses in the page and format the text as a heading.
4. From the Data folder of the Toolbox, drag a GridView control onto the page.
5. In the smart tag panel, from the Connect to Data Source list choose <
New Data Source > and then use the wizard to do the following:
a. Click Database.
b. Connect to the ExForSys database.
c. Retrieve the CourseId, CourseName and CourseDuration columns from the CourseDetails table.
6. Optionally, in the smart tag panel select the Enable paging check box.
7. In the smart tag panel, choose Edit Columns.
8. The Fields dialog box is displayed.
9. Clear the Auto-Generate Fields check box.
1. Add a new page to the Web site and name it DetailsCourse.aspx.
3. Type Students in the page and format the text as a heading.
5. In the smart tag panel, from the Choose Data Source list choose <
New Data Source >.
6. In the Select a data source type list, click Database and then click
7. From the Choose a data connection list, select the connection you created and stored earlier.
8. Click Next.
9. The wizard displays a page where you can create a SQL statement.
10. From the Name list under Table or View Options, select CourseDetails.
11. In the Columns box, check StudentId, StudentName and
12. Click WHERE.
13. From the Columns list, select CourseId.
14. From the Operators list, select =.
15. From the Source list, select QueryString.
16. This specifies that the query will select records based on the value passed into the page with the query string.
17. Under Parameter Properties, in the QueryString field box, type
18. The query will get the CourseId value from the query string, which is created when you click a
Details link in the MasterCourses.aspx page.
19. Click Add.
20. Click OK to close the Add WHERE
Clause dialog box.
21. Click Next, and then click Finish to close the wizard.
22. From the Standard node of the Toolbox, drag a Hyperlink control onto the page. Set its
Text property to Return to Courses and its
NavigateUrl property to MasterCourses.aspx.
The Master-details pages can now be tested. The DetailsCourses.aspx design screen should look as under.
1. Switch to the MasterCourses.aspx page.
2. Press CTRL+F5 to run the page.
3. Click the Details link for a coursedetails.
4. The browser displays the DetailsCourse.aspx page with course for the selected courseid. Note that the URL in the browser's Address box is: DetailsCourses.aspx?CourseId=xxx. Where xxx is the ID of the course selected.
5. Click the Return to courses link, select a different course, and click the
Details link again to test that you can view courses for any student.
Allowing Editing, Deleting, and Inserting Using a DetailsView Control
1. Right-click the DetailsView control and then click
Show Smart Tag.
2. On the Common DetailsView Tasks menu, select Enable Inserting, Enable Editing, and
Enable Deleting boxes.