PDA

Click to See Complete Forum and Search --> : Nested Dropdown list inside a datalist: Retrieve values ** Resolved **


MarkusJ_NZ
Nov 18th, 2003, 09:00 PM
Hi, I have a datalist that contains a textbox as well as a dropdown list.

For each single row in the datalist the associated dropdown list can have at least one value

Picture attached :)

What I would like to be able to do is when a single update button is clicked the textbox value along with the associated dropdown value is printed for each row in the datalist.

The number of rows in the datalist can vary. Here is my Datalist code


<asp:DataList id="DataList1" runat="server" DataKeyField="PersonID">
<ItemTemplate>
<asp:TextBox ID="txtName" Runat="server" Text='<%# Container.DataItem("Firstname") %>' Enabled="False">
</asp:TextBox>
</td>
<td>
<asp:DropDownList ID="dlNotChild" Runat="server" DataSource="<%# GetNotChild() %>" DataTextField="PersonName" DataValueField="PersonID">
</asp:DropDownList>
</td>
</ItemTemplate>
</asp:DataList>


The main datalist is bound to a dataview as is the dropdown list (GetNotChild routine)

Thanks for your time
Regards
MarkusJ

======================

I have fixed it new code below



<asp:dataList id="DataList1" runat="server" DataKeyField="DeptID">
<ItemTemplate>
<asp:TextBox ID="txtName" Runat="server" Text='<%# Container.DataItem("DeptName") %>' Enabled="False">
</asp:TextBox>
</td>
<td>
<asp:dropDownList ID="dlNotChild" Runat="server" DataSource="<%# GetNotChild() %>" DataTextField="DeptName" DataValueField="DeptName" AutoPostBack="True" OnSelectedIndexChanged="bollo">
</asp:dropDownList>
</td>
</ItemTemplate>
</asp:dataList></P>


And the main Bollo function is this...



Public Sub Bollo(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Write(CType(sender, DropDownList).SelectedItem.Text)
Response.Write(DataList1.DataKeys(CType(sender, DropDownList).SelectedIndex))
End Sub