开发者

Typed DataSet row creation doubt

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>


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜