I have 3 following dropdownlist
<asp:UpdatePanel ID="UpdatePanel_ComponentFromStore" runat="server">
<ContentTemplate>
1: ComponentFamily : store all family of components
<asp:DropDownList ID="ddlComponentFamily" runat="server"
AppendDataBoundItems="True" AutoPostBack="True"
DataSourceID="objDSComponentFamily" DataTextField="ComponentFamilyName"
DataValueField="ComponentFamilyID"
onselectedindexchanged="ddlComponentFamily_SelectedIndexChanged">
<asp:ListItem Value="-1">-- Component Family --</asp:ListItem>
</asp:DropDownList>
<asp:ObjectDataSource ID="objDSComponentFamily" runat="server"
SelectMethod="GetComponentFamily" TypeName="CMMS.DAL.ComponentFamilyFactory">
</asp:ObjectDataSource>
2. Component : store all components items base on ComponentFamily
<asp:DropDownList ID="ddlComponent" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlComponent_SelectedIndexChanged"
ontextchanged="ddlComponent_TextChanged">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="ccdComponent" runat="server"
Category="Component" Enabled="True" LoadingText="Loading List..."
ParentControlID="ddlComponentFamily" PromptText="--Component--"
ServiceMethod="GetComponentServices"
ServicePath="~/Common/Webservices/ComponentService.asmx"
TargetControlID="ddlComponent" UseContextKey="True">
</ajaxToolkit:CascadingDropDown>
3. ComponentID : store all components items without concerning which Family its belong too
<asp:DropDownList ID="ddlComponentByID" runat="server"
AppendDataBoundItems="True" AutoPostBack="True"
DataSourceID="objDSComponentByID" DataTextField="ComponentID"
DataValueField="ComponentID"
onselectedindexchanged="ddlComponentByID_SelectedIndexChanged">
<asp:ListItem Value="-1">-- Component ID --</asp:ListItem>
</asp:DropDownList>
<asp:ObjectDataSource ID="objDSComponentByID" runat="server"
SelectMethod="GetActiveComponent" TypeName="CMMS.DAL.ComponentFactory">
</asp:ObjectDataSource>
</ContentTemplate>
</asp:UpdatePanel>
I have had 2 senarios need to be perform on user selection.
Senario 1:
User can select an item in ComponentFamily, then an item in Component then an item in ComponentID will also selected base on the same value.
Senario 2:
User can select an item in ComponentID, then the ComponentFamily, and Component Item will automatically selected the related value.
Here is my code to managed the dropdownlist
protected void ddlComponent_SelectedIndexChanged(object sender, EventArgs e)
{
if ((ddlComponentByID.Items.Count > 0) && (ddlComponent.Items.Count > 0) && (ddlComponent.SelectedValue!=string.Empty))
{
ddlComponentByID.SelectedValue = ddlComponent.SelectedValue;
}
}
protected void ddlComponentFamily_SelectedIndexChanged(object sender, EventArgs e)
{
ddlComponentByID.SelectedValue = "-1";
}
protected void ddlComponentByID_SelectedIndexChanged(object sender, EventArgs e)
{
if ((ddlComponentByID.SelectedItem.Value != "-1") || (ddlComponentByID.SelectedItem.Value != string.Empty)){
Component objComponent = (Component)_objCom.GetActiveComponentByID(ddlComponentByID.SelectedItem.Value)[0];
ddlComponentFamily.SelectedValue = objComponent.ComponentFamilyID.ToString();
ccdComponent.SelectedValue = objComponent.ComponentID;
}
}
I have no idea, why the ddlComponent_SelectedIndexChanged is always fire event I just click on ddlComponentByID. It's not
just only that component, but also other events on the components outside the Update Panel.
Could you please guide me how could I solve this problem?
Best regards,
Veasna