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

DropDownlist postback problem in radGrid

1 Answer 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ravi
Top achievements
Rank 1
ravi asked on 08 Dec 2008, 05:46 PM
Hi

Here i have problem with post back with 2 dropdown inside radgrid
we have placed 2 dropdown controls  inside form template of radgrid.
i want to get values depends on first dropdown to fill second dropdown.
how can we implement in CS file.

my html code.

<

telerik:RadGrid  ID="RadGrid1"   runat="server"   Skin="Office2007" GridLines="None"  PageSize = "10"  AllowPaging="True"  PagerStyle-Mode="NextPrevAndNumeric"  AllowSorting="True"  

ShowStatusBar="true"  AutoGenerateColumns="False" 

AllowMultiRowSelection ="true"  ClientSettings-Selecting-AllowRowSelect="true"  onneeddatasource="RadGrid1_NeedDataSource" >  

 

<MasterTableView GridLines="None" HeaderStyle-CssClass="grid_hd" Width="100%" CommandItemStyle-CssClass="grid_cmd CommandItemDisplay="TopAndBottom" DataKeyNames="RoleID" InsertItemPageIndexAction="ShowItemOnFirstPage"> 

 

<Columns>  ....  

 </Columns<EditFormSettings EditFormType="Template">  <FormTemplate>  <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> <td> <asp:DropDownList ID="drop1" runat="server" AutoPostBack="true"  

onselectedindexchanged="drop1_SelectedIndexChanged" > <asp:ListItem Value="1">ONE</asp:ListItem> <asp:ListItem Value="2">TWO</asp:ListItem> 

 

</asp:DropDownList> <asp:DropDownList ID="drop2" runat="server"> </asp:DropDownList> </td> </tr>

 

 

 </table> </FormTemplate></EditFormSettings></MasterTableView> </telerik:RadGrid>  


can plz let me if u know any solution.

 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Dec 2008, 05:50 AM
Hello Ravi,

Check out the following code to achieve the required scenario of populating one dropdown on the selection changed event of the other.
aspx:
 <EditFormSettings EditFormType="Template" > 
            <FormTemplate> 
           <table cellpadding="0" cellspacing="0" border="0" width="100%"<tr> <td>  
                <asp:DropDownList ID="DropDownList1" AutoPostBack="true"  runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
                <asp:ListItem Text="ONE" Value="1">                 
                </asp:ListItem>                  
                 <asp:ListItem Text="TWO" Value="2">                 
                </asp:ListItem> 
                </asp:DropDownList> 
                </td> 
                <td> 
                <asp:DropDownList ID="DropDownList2" runat="server"
                </asp:DropDownList> 
            </td> </tr> </table> 
          </FormTemplate>            
 </EditFormSettings> 

cs:
 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        DropDownList ddl1 = (DropDownList)sender; 
        GridEditableItem editItem = (GridEditableItem)ddl1.NamingContainer; 
        DropDownList ddl2 = (DropDownList)editItem.FindControl("DropDownList2"); 
        //Assign the datasource for the dropdown
        ddl2.DataSource""
        
    } 

Thanks
Princy.
Tags
Grid
Asked by
ravi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or