Last post Mar 07, 2013 06:06 AM by sgsensai
Feb 24, 2013 12:17 PM|sgsensai|LINK
I bounded two DropDownLists via two different XMLDataSources to one XML. Both XMLDataSources were initialised with a XPath argument whereby the second DataSource depend on the first one. If I perform a SelectedIndexChanged at the first DropDown I update the
second DataSource with a new XPath to get a new List for my second DropDown. This works well, but NOT if i perform a SelectedIndexChanged to the Element which was initialized. An Example:
Dropdown1: Initialized with A,B and C; A is selected
Dropdown2: Initialized with Content of A for e.g. A1,A2,A3
If I click B
Dropdown gets initialized with B1,B2,B3
If i go back to A1
Nothing happened. No update in my DropDown2..
I can switch between B and C and it works well, but i cannot switch back to the initialized one (A).
My code as follows:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<asp:Label ID="Label1" runat="server" Text="Parent: "></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="myXML_1" DataTextField="name" DataValueField="name"
<asp:XmlDataSource ID="myXML_1" runat="server"
<asp:Label ID="Label2" runat="server" Text="Child: "></asp:Label>
<asp:DropDownList ID="DropDownList2" runat="server"
DataSourceID="myXML_2" DataTextField="name" DataValueField="name"
<asp:XmlDataSource ID="myXML_2" runat="server"
<asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged"/>
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
myXML_2.XPath = "/MyProg/Parent[@name='" + DropDownList1.Text + "']/Child";
I'm really looking forward to any help.
Feb 28, 2013 02:39 AM|ToughMan|LINK
Mar 07, 2013 06:06 AM|sgsensai|LINK
thanks for reply!
There's no error occur. If i switch back to the entry A (which was the initalized entry) it just happens nothing! DropDownList2 don't refresh and still keep values (e.g. C1, C2, C3 instead of refreshing and containing A1, A2, A3) of the last clicked entry
(in this case C).
I cannot find an error in my code, it works well by switching all other entries instead of the initialized one (A). In a testcase, i extended the XML file with a "dummy entry" such as "<parent name="Please Select"></parent>. Then, the initialized element
is not A, it's "Please Select" after this, i can switch between A, B and C and the DropDownList2 gets updated with no problems, but NOT if I switch back again to "Please Select". The expected behaviour should be an empty DropDownList2, because no childs are
given to this parent.
Again: DropDownList2 should get updated in dependence on DropDownList1. But DropDownList2 don't update if I switch back to that element which was initialized with DropDownList1. (e.g. "A" or "Please Select").
Hopefully you understand my problem