V
Veasna
Guest
I have 3 following dropdownlist
<asp:UpdatePanel ID="UpdatePanel_ComponentFromStore" runat="server
<ContentTemplate>
1: ComponentFamily : store all family of components
<aspropDownList 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>
</aspropDownList>
<asp:ObjectDataSource ID="objDSComponentFamily" runat="server"
SelectMethod="GetComponentFamily" TypeName="CMMS.DAL.ComponentFamilyFactory
</asp:ObjectDataSource>
2. Component : store all components items base on ComponentFamily
<aspropDownList ID="ddlComponent" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlComponent_SelectedIndexChanged
</aspropDownList>
<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
<aspropDownList 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>
</aspropDownList>
<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 one:
User can select an item in ComponentFamily, then an item in Component.
Once user finished select an item in Component,
then an item in ComponentID will also selected base on the same value.
Senario two:
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. Its not
just only that component, but also other on events on other components outside the Update Panel.
Could you please guide me how could I solve this problem?
Best regards,
Veasna
Mex
Continue reading...
<asp:UpdatePanel ID="UpdatePanel_ComponentFromStore" runat="server
<ContentTemplate>
1: ComponentFamily : store all family of components
<aspropDownList 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>
</aspropDownList>
<asp:ObjectDataSource ID="objDSComponentFamily" runat="server"
SelectMethod="GetComponentFamily" TypeName="CMMS.DAL.ComponentFamilyFactory
</asp:ObjectDataSource>
2. Component : store all components items base on ComponentFamily
<aspropDownList ID="ddlComponent" runat="server" AutoPostBack="True"
onselectedindexchanged="ddlComponent_SelectedIndexChanged
</aspropDownList>
<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
<aspropDownList 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>
</aspropDownList>
<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 one:
User can select an item in ComponentFamily, then an item in Component.
Once user finished select an item in Component,
then an item in ComponentID will also selected base on the same value.
Senario two:
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. Its not
just only that component, but also other on events on other components outside the Update Panel.
Could you please guide me how could I solve this problem?
Best regards,
Veasna
Mex
Continue reading...