Access editform from client side

2 posts, 0 answers
  1. Tina
    Tina avatar
    130 posts
    Member since:
    Jul 2011

    Posted 04 Apr 2012 Link to this post

    How to access the dropdownlist value on client side in button click
      <EditFormSettings EditFormType="Template">
                            <asp:DropDownList ID="editDropDown" runat="server">
                                <asp:ListItem Text="Item1"></asp:ListItem>
                                <asp:ListItem Text="Item2"></asp:ListItem>
                                <asp:ListItem Text="Item3"></asp:ListItem>
                            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                            <asp:Button ID="btn" Text="btn" runat="server" OnClientClick="ddlValue();" />
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Apr 2012 Link to this post

    Hello Tina,

    You can access the dropdownlist in ItemCreated and pass the ClientID to access it from client side. Here is the sample code.
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
     if ((e.Item is GridEditFormItem && e.Item.IsInEditMode))
        GridEditFormItem editFormItem = (GridEditFormItem)e.Item;
        DropDownList ddl = (DropDownList)editFormItem.FindControl("editDropDown");
        RadGrid1.Controls.Add(new LiteralControl("<script type='text/javascript'>window['ddlvalue'] = '" + ddl.ClientID + "';</script>"));
    function ddlvalue()
     var ddl = document.getElementById(window['ddlvalue']);
     if (!ddl)
       alert("no item is edited");
       return false;
      alert("value is: " + ddl.value);

Back to Top