This is a migrated thread and some comments may be shown as answers.

radgrid editformsetting control event

2 Answers 114 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anup
Top achievements
Rank 1
Anup asked on 15 Jun 2016, 08:39 PM

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 Answers, 1 is accepted

Sort by
0
Anup
Top achievements
Rank 1
answered on 16 Jun 2016, 12:11 PM
Some body pls help....need the solution urgently
0
Kostadin
Telerik team
answered on 20 Jun 2016, 10:42 AM
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.
Tags
General Discussions
Asked by
Anup
Top achievements
Rank 1
Answers by
Anup
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or