0

I've created a DataSet with 2 Data Tables exported from a DataBase with 2 related tables:

TableA (idTableA, name, idTableB) 
TableB (idTableB)

Now what I want to do is to create a Data Row of the type TableA using:

DataSet.TableA.AddTableARow(lblTableAName.Text.Text, ??? )

The ??? part ask for a DataSet.TableBRow, that I want to be give from a Drop Down List from the page form that is bound to a TableB TableData Data Source.

On debug I've gone trough both the Drop Down List instance and the Data Source instance, but found no DataSet.TableBRow result :(

Sorry for the confusing question, but in a more basic explanation is:

Use the Drop Down List selected TableB row to create a TableA row...

Got me?

Hope so...

Thanks

For more information:

The Drop Down List and it's Data Source code

<asp:DropDownList ID="campaignState" runat="server" 
                                DataSourceID="CampaignStateDataSource" DataTextField="name" 
                                DataValueField="idCampaignState" />
                            <asp:ObjectDataSource ID="CampaignStateDataSource" runat="server" 
                                DeleteMethod="Delete" InsertMethod="Insert" 
                                OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
                                TypeName="OutboundSMS.Data.OutboundSMSDataSetTableAdapters.CampaignStateTableAdapter"

                                UpdateMethod="Update">
                                <DeleteParameters>
                                    <asp:Parameter Name="Original_idCampaignState" Type="Int32" />
                                    <asp:Parameter Name="Original_name" Type="String" />
                                </DeleteParameters>
                                <InsertParameters>
                                    <asp:Parameter Name="idCampaignState" Type="Int32" />
                                    <asp:Parameter Name="name" Type="String" />
                                </InsertParameters>
                                <UpdateParameters>
                                    <asp:Parameter Name="name" Type="String" />
                                    <asp:Parameter Name="Original_idCampaignState" Type="Int32" />
                                    <asp:Parameter Name="Original_name" Type="String" />
                                </UpdateParameters>
                            </asp:ObjectDataSource>
1
  • could ou put some code? specially the one binding the DropDownList to TableB, specially what is in DataValueField?
    – manji
    Apr 8, 2011 at 12:15

1 Answer 1

0

From your code, you are binding DropDownList's DataValueField to idCampaignState column from TableB:

So, to get the TableBRow you have to search for it in the table using dropDownList.SelectedItem.Value which will contain the idCampaignState of that row:

for example, if idCampaignState is the primary key for TableB:

tableBRow = tableB.FindByidCampaignState((int)dropDownList.SelectedItem.Value)

More informations here:DropDownList Web Server Control

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.