capture EditForm combobox selectedIndexChnaged

3 posts, 1 answers
  1. Kushal
    Kushal avatar
    11 posts
    Member since:
    Sep 2011

    Posted 12 Dec 2011 Link to this post

    In Edit form , I have two comboboxes : combobox1 & combobox2. On change of combobox1 value, I want to set combobox2 value. The problem is, I am not able to handle combobox1 selectedIndexChnaged event.

    Can anyone give a code sample or pointer on how to achieve it? Thank you very much in advance.


    Here is the ASPX code :

     <telerik:TreeListTemplateColumn DataField="PricingTypeName" UniqueName="PricingTypeName" HeaderText="PricingType" >
                     <ItemTemplate>
                     <%# Eval("PricingTypeName")%>
                     </ItemTemplate>
                     <EditItemTemplate>
                            <asp:DropDownList ID="combobox1" runat="server">
                            </asp:DropDownList>
                      </EditItemTemplate>
                   
                     </telerik:TreeListTemplateColumn>

      <telerik:TreeListTemplateColumn DataField="PurchaseUnitofMeasureName" UniqueName="PurchaseUnitofMeasureName" HeaderText="PurchaseUnitofMeasure" >
                     <ItemTemplate>
                     <%# Eval("PurchaseUnitofMeasureName")%>
                     </ItemTemplate>
                     <EditItemTemplate>
                            <asp:DropDownList ID="combobox2" runat="server">
                            </asp:DropDownList>
                      </EditItemTemplate>
                    
                     </telerik:TreeListTemplateColumn>


  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 Dec 2011 Link to this post

    Hello,

    You can handle the SelectedIndexChanged as shown below.
    ASPX:
    <EditItemTemplate>
     <asp:DropDownList ID="ddlst" runat="server" AutoPostBack="true" onselectedindexchanged="ddlst_SelectedIndexChanged" >
      <asp:ListItem Text="1"></asp:ListItem>
      <asp:ListItem Text="2"></asp:ListItem>
      <asp:ListItem Text="3"></asp:ListItem>
     </asp:DropDownList>
     <asp:DropDownList ID="ddlst1" runat="server">
      <asp:ListItem Text="1"></asp:ListItem>
      <asp:ListItem Text="2"></asp:ListItem>
      <asp:ListItem Text="3"></asp:ListItem>
     </asp:DropDownList>
    </EditItemTemplate>

    CS:
    protected void ddlst_SelectedIndexChanged(object sender, EventArgs e)
       {
           DropDownList list = (DropDownList)sender;
           TreeListEditableItem item = (TreeListEditableItem)list.NamingContainer;
           DropDownList ddl = item.FindControl("ddlst1") as DropDownList;
              ....... .... ..... //your code
       }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kushal
    Kushal avatar
    11 posts
    Member since:
    Sep 2011

    Posted 12 Dec 2011 Link to this post

    Thanks Princy. It works.
Back to Top