Here is an example from a FormView where I have an hidden Textbox containing an ID from a child table, which is related to an entry in a primary table.
This is just one example of many controls I have in this FormView... it is bound to a single ID in my DataSource. You will see the DropDownList (representing a friendly listing of possible IDs for my FormView field) has its own DataSource in there with it. The sdsApplicationNames DS populates my dropdownlist. The Dropdownlist has an event which (during autopostback) calls a SelectedIndexChanged method (This will also be below). The initial value of the hidden field is handled naturally in the FormView and its Datasource, but the DropDownList's initially selected value is handeld in the event handler for the DropdownList.DataBound event (will also be below)
<EditItemTemplate>
APPLICATION:<br />
<asp:TextBox ID="APPLICATION_IDTextBox" runat="server"
Text='<%# Bind("APPLICATION_ID", "{0}") %>'
Visible="False" Width="56px"></asp:TextBox>
<asp:DropDownList ID="ddlEditApplicationNames" runat="server"
AppendDataBoundItems="True"
AutoPostBack="True" DataSourceID="sdsApplicationNames"
DataTextField="NAME" DataValueField="APPLICATION_ID"
OnDataBound="ddlEditApplicationNames_DataBound"
OnSelectedIndexChanged="ddlEditApplicationNames_SelectedIndexChanged">
<asp:ListItem Selected="True"Copyright ©2007 Wil Dobson