radgrid editformsetting control event

3 posts, 0 answers
  1. Anup
    Anup avatar
    2 posts
    Member since:
    Jun 2016

    Posted 15 Jun Link to this post

    Hi ,

     

    I am new to this radgrid . Need some help from anyone who has faced this issue. In the EditFormSetting in the radgrid i have two raddropdownlist. The functionality that i need is ..on selectionindexchange of the first dropdownlist,the contents of second dropdownlist need to be populated from a datasource. How do i achieve this? The problem i am facing is i am not able to access the dropdownlist control in the selectionchanged event of the first dropdownlist.

     

      <EditFormSettings EditFormType="Template">
                        <FormTemplate>
                            <table style="width: 500px">
                              <tr>
                                    <td>
                                        <asp:Label ID="Label1" runat="server" Text="lblDropdown1:" Visible="true"></asp:Label>
                                    </td>
                                    <td class="tableCellRight" style="width: 85%">
                                        <asp:DropDownList ID="rd_Dropdown1" runat="server" AppendDataBoundItems="True" AutoPostBack="True"   Visible="true" OnSelectedIndexChanged="rd_Dropdown1_SelectedIndexChanged" DataSourceID="ds_dropdown1" DataTextField="field2" DataValueField="field1">
                                            <Items>
                                                <asp:ListItem runat="server" Text="--Select item--" Value="NA" />
                                                 
                                                
                                            </Items>
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Label ID="Label2" runat="server" Text="lbldropdown2:" Visible="False"></asp:Label>
                                    </td>
                                    <td class="tableCellRight" style="width: 85%">
                                       <telerik:RadDropDownList ID="rd_dropdown2" runat="server" AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="ds_dropdown2"  DataTextField="field2" DataValueField="field1"  Visible="False">
                                            <Items>
                                                <telerik:DropDownListItem runat="server" Text="--Select names--" Value="N/A" />
                                                
                                            </Items>
                                        </telerik:RadDropDownList> 
                                    </td>
                                </tr>
                                
                            </table>
                        </FormTemplate>
                    </EditFormSettings>

     <asp:SqlDataSource ID="ds_dropdown1" runat="server" ConnectionString="<%$ ConnectionStrings:xxConnectionString%>" SelectCommand="SELECT field1, field2 FROM [table1] ">
                       </asp:SqlDataSource>

     <asp:SqlDataSource ID="ds_dropdown2" runat="server" ConnectionString="<%$ ConnectionStrings:xxConnectionString %>" SelectCommand="SELECT [field1], [field2] FROM [table1] WHERE (somecondition)">          
            </asp:SqlDataSource>

    codebehindfile event code

     protected void rd_Dropdown1_SelectedIndexChanged(object sender,EventArgs e)
        {
           //what code is required here to fetch or access dropdown2 control so that i bind it with suitable sqlcommand?


       
            //RadGrid1.DataBind();
        }

     

     

  2. Anup
    Anup avatar
    2 posts
    Member since:
    Jun 2016

    Posted 16 Jun Link to this post

    Some body pls help....need the solution urgently
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kostadin
    Admin
    Kostadin avatar
    1711 posts

    Posted 20 Jun Link to this post

    Hi Anup,

    Please check out the following code library which demonstrates how to create a related RadComboBox controls in RadGrid edit form. Generally you can use the NamingContainer property to access the EditFormItem and then you can use the approach from the following help article to access the controls in it.

    Regards,
    Kostadin
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top