| Home | Forums | Reviews | Guides | Newsgroups | Register | Search |
![]() |
| Thread Tools |
| Tyler Lynch |
|
|
|
| |
|
Phil H
Guest
Posts: n/a
|
On 7 Dec, 19:56, Tyler Lynch <Tyler Ly...@discussions.microsoft.com>
wrote: > CASE NUMBER: SRX071207601166 > > To preface, all data access is done through ObjectDatasounces that are bound > to StronglyTyped Datasets (VS.NET generated). All UI controls are bound to > those ObjectDataSources through standard UI binding techniques (point/click). > > I have a DetailsView used for inserting records (Companies). Inside that > DetailsView I have added a new column template, this template is going to be > used to add Officers of the company. > > Behind the scenes there is a Companies table and a Officers table. The > relationships are N number of Officers to a single company. > > My problem is that if I add a DataView in the template to show a list of > Officers, and a DetailsView to that template to allow inserting of new > Officers how do I allow users to insert new Officers of the Company, before > the Company record is actually inserted into the database? I need the > Officers associated with this company, and the user workflow would be > burdened if users had to first create a company, and then move to another > screen to enter Officers and other attributes. > > ==================CODE================== > > <asp > runat="server" AutoGenerateRows="False" DataSourceID="CompanyInfoDS" > DefaultMode="Insert" HeaderText="Add Company" Height="50px" > Width="500px" DataKeyNames="CompanyID" GridLines="Vertical" > HorizontalAlign="Left" OnItemCommand="CompanyDetailsView_ItemCommand" > OnItemInserted="CompanyDetailsView_ItemInserted" Visible="False"> > <Fields> > <asp:BoundField DataField="ID" HeaderText="ID" > InsertVisible="False" ReadOnly="True" > SortExpression="ID" /> > <asp:TemplateField HeaderText="Officers"> > <InsertItemTemplate> > <asp:GridView ID="OfficersGridView" runat="server" > AutoGenerateColumns="False" DataKeyNames="OfficerID" > DataSourceID="OfficerDS" EmptyDataText="No > Officers Defined" GridLines="None" ShowFooter="True"> > <Columns> > <asp:CommandField ShowDeleteButton="True" > ShowEditButton="True" /> > <asp:BoundField DataField="OfficerID" > HeaderText="OfficerID" InsertVisible="False" > ReadOnly="True" > SortExpression="OfficerID" Visible="False" /> > <asp:BoundField DataField="CompanyID" > HeaderText="CompanyID" SortExpression="CompanyID" > Visible="False" /> > <asp:BoundField DataField="Name" > HeaderText="Name" SortExpression="Name" /> > <asp:BoundField DataField="OfficerTitle" > HeaderText="OfficerTitle" SortExpression="OfficerTitle" /> > <asp:BoundField DataField="MailingAddr1" > HeaderText="MailingAddr1" SortExpression="MailingAddr1" /> > <asp:BoundField DataField="MailingAddr2" > HeaderText="MailingAddr2" SortExpression="MailingAddr2" /> > <asp:BoundField DataField="MailingAddr3" > HeaderText="MailingAddr3" SortExpression="MailingAddr3" /> > <asp:BoundField DataField="City" > HeaderText="City" SortExpression="City" /> > <asp:TemplateField HeaderText="StateID" > SortExpression="StateID"> > <EditItemTemplate> > <asp:TextBox ID="TextBox1" > runat="server" Text='<%# Bind("StateID") %>'></asp:TextBox> > </EditItemTemplate> > <ItemTemplate> > <asp:Label ID="Label1" > runat="server" Text='<%# Bind("StateID") %>'></asp:Label> > </ItemTemplate> > </asp:TemplateField> > <asp:BoundField DataField="PostalCode" > HeaderText="PostalCode" SortExpression="PostalCode" /> > <asp:TemplateField HeaderText="CountryID" > SortExpression="CountryID"> > <EditItemTemplate> > <asp:TextBox ID="TextBox2" > runat="server" Text='<%# Bind("CountryID") %>'></asp:TextBox> > </EditItemTemplate> > <ItemTemplate> > <asp:Label ID="Label2" > runat="server" Text='<%# Bind("CountryID") %>'></asp:Label> > </ItemTemplate> > </asp:TemplateField> > </Columns> > <HeaderStyle BackColor="#5D7B9D" > ForeColor="White" /> > </asp:GridView> > <asp:ObjectDataSource ID="OfficerDS" runat="server" > DeleteMethod="Delete" InsertMethod="Insert" > OldValuesParameterFormatString="original_{0}" > SelectMethod="GetDataByOfficer" > TypeName="DataObjects.CompanyDataSetTableAdapters. OfficerTableAdapter" > UpdateMethod="Update"> > <DeleteParameters> > <asp > Type="Int32" /> > <asp > Type="Int32" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="Int32" /> > <asp > Type="String" /> > <asp > Type="Int32" /> > </DeleteParameters> > <UpdateParameters> > <asp > /> > <asp > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > <asp > <asp > Type="String" /> > <asp > /> > <asp > Type="Int32" /> > <asp > Type="Int32" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="Int32" /> > <asp > Type="String" /> > <asp > Type="Int32" /> > <asp > /> > </UpdateParameters> > <InsertParameters> > <asp > /> > <asp > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > <asp > <asp > Type="String" /> > <asp > /> > </InsertParameters> > <SelectParameters> > <asp:ControlParameter > ControlID="OfficersGridView" Name="OfficerID" PropertyName="SelectedValue" > Type="Int32" /> > </SelectParameters> > </asp:ObjectDataSource> > <asp > runat="server" AutoGenerateRows="False" > DataKeyNames="OfficerID" > DataSourceID="OfficerDS" DefaultMode="Insert" Height="50px" > Width="125px"> > <Fields> > <asp:BoundField DataField="OfficerID" > HeaderText="OfficerID" InsertVisible="False" > ReadOnly="True" > SortExpression="OfficerID" /> > <asp:BoundField DataField="CompanyID" > HeaderText="CompanyID" SortExpression="CompanyID" /> > <asp:BoundField DataField="Name" > HeaderText="Name" SortExpression="Name" /> > <asp:BoundField DataField="OfficerTitle" > HeaderText="OfficerTitle" SortExpression="OfficerTitle" /> > <asp:BoundField DataField="MailingAddr1" > HeaderText="MailingAddr1" SortExpression="MailingAddr1" /> > <asp:BoundField DataField="MailingAddr2" > HeaderText="MailingAddr2" SortExpression="MailingAddr2" /> > <asp:BoundField DataField="MailingAddr3" > HeaderText="MailingAddr3" SortExpression="MailingAddr3" /> > <asp:BoundField DataField="City" > HeaderText="City" SortExpression="City" /> > <asp:BoundField DataField="StateID" > HeaderText="StateID" SortExpression="StateID" /> > <asp:BoundField DataField="PostalCode" > HeaderText="PostalCode" SortExpression="PostalCode" /> > <asp:BoundField DataField="CountryID" > HeaderText="CountryID" SortExpression="CountryID" /> > <asp:CommandField ShowEditButton="True" > ShowInsertButton="True" /> > </Fields> > </asp > <asp:ImageButton ID="ImageButton1" runat="server" > ImageUrl="~/images/add.png" OnClick="ImageButton1_Click" /> > </InsertItemTemplate> > </asp:TemplateField> > <asp:CommandField ShowDeleteButton="True" > ShowEditButton="True" ShowInsertButton="True" /> > </Fields> > <RowStyle BackColor="#F7F6F3" /> > <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" > ForeColor="White" /> > <AlternatingRowStyle BackColor="White" /> > <CommandRowStyle BorderStyle="None" Font-Bold="True" /> > </asp > > <asp:ObjectDataSource ID="CompanyInfoDS" runat="server" > DeleteMethod="Delete" InsertMethod="Insert" > OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" > > TypeName="DataObjects.CompanyDataSetTableAdapters. CompanyTableAdapter" > UpdateMethod="Update"> > <DeleteParameters> > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > Type="DateTime" /> > <asp > <asp > Type="Int64" /> > <asp > Type="Int64" /> > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > <asp > <asp > /> > <asp > <asp > Type="String" /> > <asp > <asp > <asp > /> > <asp > <asp > <asp > /> > <asp > /> > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > </DeleteParameters> > <UpdateParameters> > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > Type="DateTime" /> > <asp > <asp > Type="Int64" /> > <asp > Type="Int64" /> > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > Type="String" /> > <asp > Type="String" /> > <asp > Type="String" /> > <asp > <asp > <asp > /> > <asp > <asp > Type="String" /> > <asp > <asp > <asp > /> > <asp > <asp > <asp > /> > <asp > /> > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > </UpdateParameters> > <InsertParameters> > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > <asp > </InsertParameters> > </asp:ObjectDataSource> The Officers table will contain a foreign key (e.g. CompanyID) pointing to a unique record in the Companies table. When entering records (or rows) into the Officers table, the foreign key to the Companies table does not necessarily have to be entered at the same time, but will need to be updated at some point after the new Officer entry process. Other processes involving the new Officers could be carried out if required pending the completion of Company data entry. To facilitate this the Company ID field could be left null or contain some default value to show it has not yet been allocated. A query based on this could be used to present the operator with a list of Officers with unallocated Companies, as part of a subsequent data entry process carried out after the new Company records have been entered. Any use? |
|
|
|
|
|||
|
|||
| Phil H |
|
|
|
| |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reusing same DetailsView for both Inserting and Editing | David Ching | ASP .Net | 0 | 08-29-2007 09:17 PM |
| Inserting/Updating records in a DetailsView | 47computers@gmail.com | ASP .Net | 0 | 03-28-2007 12:49 AM |
| Problems with Walkthrough: Editing and Inserting Data in Web Pages with the DetailsView Web Server Control" | tom c | ASP .Net | 0 | 09-19-2006 10:11 PM |
| match muliple header records to associated detail records | Luke Airig | XML | 0 | 12-31-2003 12:06 AM |
| How do I: Main thread spawn child threads, which child processes...control those child processes? | Jeff Rodriguez | C Programming | 23 | 12-09-2003 11:06 PM |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc..
SEO by vBSEO ©2010, Crawlability, Inc. |




