|
|
Subject:
Creating a Web Form with a multiple data tables in Visual Web Developer 2005
Category: Computers > Programming Asked by: tbonehwd-ga List Price: $62.50 |
Posted:
22 Feb 2006 13:53 PST
Expires: 27 Feb 2006 09:59 PST Question ID: 448523 |
I am trying to create a form where users can enter new Title information, the title header information is being stored in a table called Books. In addition to the information stored in Books I have another table called Subjects the Subjects table has the BookID in it as a foreign key, each book can have multiple subjects. Tables Books - BookID (varchar50) Primary Key - Title (varchar50) Subjects - iSubjectID (int) Primary Key auto-increment - BookID (varchar50) - Subject (varchar50) What I want to accomplish is when the form loads if the book has subjects tied to it display them in a detailsview (dvSubject) with paging turned on allowing the user to edit and delete however on insert I do not want to make the user have to type the BookID it should be able to pull it from dvBook. If when the form loads and does not have any subject records tied to that book I would like dvSubject to display with defaultmode=insert so users can add a subject if they want to. I have alot more fields to add but I wanted to keep this as simple as possible and have been racking my brain on how to do this and I know it can not be that hard, below is the code that I have so far for this. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="BookEntry.aspx.vb" Inherits="BookEntry" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <asp:ObjectDataSource ID="odsBook" runat="server" InsertMethod="InsertBook" OldValuesParameterFormatString="original_{0}" SelectMethod="GetByBookID" TypeName="BooksTableAdapters.BooksTableAdapter" UpdateMethod="UpdateBook" DeleteMethod="Delete"> <UpdateParameters> <asp:Parameter Name="BookID" Type="String" /> <asp:Parameter Name="Title" Type="String" /> <asp:Parameter Name="Original_BookID" Type="String" /> </UpdateParameters> <SelectParameters> <asp:QueryStringParameter Name="BookID" QueryStringField="BookID" Type="String" /> </SelectParameters> <InsertParameters> <asp:Parameter Name="BookID" Type="String" /> <asp:Parameter Name="Title" Type="String" /> </InsertParameters> <DeleteParameters> <asp:Parameter Name="Original_BookID" Type="String" /> </DeleteParameters> </asp:ObjectDataSource> <asp:DetailsView ID="dvBook" runat="server" AutoGenerateRows="False" DataKeyNames="BookID" DataSourceID="odsBook" Height="50px" Width="446px" > <Fields> <asp:BoundField DataField="BookID" HeaderText="BookID" SortExpression="BookID" /> <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" /> <asp:CommandField ShowEditButton="True" ShowInsertButton="True" ShowDeleteButton="True" /> </Fields> </asp:DetailsView> <asp:ObjectDataSource ID="odsSubject" runat="server" DeleteMethod="DeleteSubject" InsertMethod="InsertSubject" OldValuesParameterFormatString="original_{0}" SelectMethod="GetSubjectByBookID" TypeName="BooksTableAdapters.SubjectsTableAdapter" UpdateMethod="UpdateSubject"> <DeleteParameters> <asp:Parameter Name="Original_iSubjectID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="BookID" Type="String" /> <asp:Parameter Name="Subject" Type="String" /> <asp:Parameter Name="Original_iSubjectID" Type="Int32" /> </UpdateParameters> <SelectParameters> <asp:ControlParameter ControlID="dvBook" Name="BookID" PropertyName="SelectedValue" Type="String" /> </SelectParameters> <InsertParameters> <asp:Parameter Name="BookID" Type="String" /> <asp:Parameter Name="Subject" Type="String" /> </InsertParameters> </asp:ObjectDataSource> <asp:DetailsView ID="dvSubject" runat="server" AllowPaging="True" AutoGenerateRows="False" DataKeyNames="iSubjectID" DataSourceID="odsSubject" Height="50px" HorizontalAlign="Left" Width="445px"> <Fields> <asp:BoundField DataField="iSubjectID" HeaderText="iSubjectID" InsertVisible="False" ReadOnly="True" SortExpression="iSubjectID" Visible="False" /> <asp:BoundField DataField="BookID" HeaderText="BookID" SortExpression="BookID" /> <asp:BoundField DataField="Subject" HeaderText="Subject" SortExpression="Subject" /> <asp:CommandField ShowEditButton="True" ShowDeleteButton="True" ShowInsertButton="True" /> </Fields> </asp:DetailsView> </form> </body> </html> | |
|
|
There is no answer at this time. |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |