2.0: two dependent drop down lists

R

RAM

I need to have two drop down lists in a edited row of a data list. One drop
down list should contain Groups and the second one should contain Materials
from *selected* group.
Thus, I have written:

<asp:SqlDataSource ID="GroupsList" runat="server"
ConnectionString="..." SelectCommand="SELECT ID, Name FROM Groups" />
<asp:SqlDataSource ID="MaterialsList" runat="server"
ConnectionString="..." SelectCommand="SELECT ID, Name FROM Materials WHERE
Group = @Group" >
<SelectParameters>
<asp:FormParameter FormField="ChosenGroup" Name="Group"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:HiddenField ID="ChosenGroup" runat="server" />
<asp:DataList ID="PositionsList" runat="server"
OnEditCommand="..." OnUpdateCommand="..." OnCancelCommand="..."
OnDeleteCommand="..." >
...
<EditItemTemplate>
<tr>
<td>
<asp:DropDownList ID="GroupEdit" runat="server"
DataSourceID="GroupsList" DataTextField="Name"
DataValueField="ID"
OnSelectedIndexChanged="GroupEdit_Changed">
<asp:DropDownList ID="MaterialEdit" runat="server"
DataSourceID="MaterialsList" DataTextField="Name"
DataValueField="Number" />
<td>
...
</asp:DataList>

The problem is that GroupEdit_Changed is not called when I change group in
the drop down list during editing of a PositionsList row. In
GroupEdit_Changed I have written:

protected void GroupEdit(object sender, EventArgs e)
{
ChosenGroup.Value =
((DropDownList)PositionsList.FindControl("GroupEdit")).SelectedValue;
}

Could you help me please? Thank you!
/RAM/
 
T

Tiger

I am having a similar to the one listed. I have 2 dropdowns where the
2nd one is dependent on the selection in the first.

What is the basic backend code that is needed for this type of
situation?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top