Hi, I did it using a trick: 1- I used a HiddenField as one of my Bound fields in the DataList 2- I bound my key column to the HiddenField and to the ToolTip of your first DropDownList 3- I used drp_SelectedIndexChanged handler which is event handler of the first DropDownList to fill the second DropDown. Here is my sample(the most important parts):
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1"
onselectedindexchanged="DataList1_SelectedIndexChanged" RepeatColumns="5">
<ItemTemplate>
<asp:HiddenField runat="server" ID="hiddenField" Value='<%# Eval("TableSeq") %>' />
<asp:DropDownList runat="server" ID="drp" AutoPostBack="true" ToolTip='<%# Eval("TableSeq") %>'
onselectedindexchanged="drp_SelectedIndexChanged">
<asp:ListItem Value="1">1</asp:ListItem>
<asp:ListItem Value="2">2</asp:ListItem>
</asp:DropDownList>
<br />
<asp:DropDownList ID="drp2" runat="server" Height="16px">
<asp:ListItem Value="5"></asp:ListItem>
<asp:ListItem Value="4">4</asp:ListItem>
</asp:DropDownList>
<br />
</ItemTemplate>
</asp:DataList>
and here is code behind:
protected void drp_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList drop2 ;
DropDownList drp = (DropDownList)sender;
string key = drp.ToolTip;
foreach (DataListItem item in DataList1.Items)
{
if (((HiddenField)item.FindControl("hiddenField")).Value == key)
{ //found
drop2 = (DropDownList)item.FindControl("drp2");
drop2.Items.Add(new ListItem("X", "X"));
return;
}
}
}
I hope it will help, Cheers.