telerik:GridDropDown SelectindexChanged event

2 posts, 0 answers
  1. Rahul Barpha
    Rahul Barpha avatar
    15 posts
    Member since:
    Mar 2010

    Posted 05 May 2010 Link to this post

    Hello,

    I Have a problen related to "telerik:GridDropDownColumn" ,
    i have two GridDropDownlist in telerik radgrid when i going edit mode
     i want to call first GridDropDown selectindexchange event and get selected value and pass to second GridDropDown

    SqlDataSource as a difault value.
    Plz anyone Help me...

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

    Posted 05 May 2010 Link to this post

    Hi Rahul Barpha,

    Access the DropDownList control rendered in EditForm and attach the 'SelectedIndexChanged' event from code behind in ItemCreated event. Then in the SelectedIndexChanged event, you can easily access second DropDownList and set the value. Here is the code example.

    ASPX:
     
        <telerik:GridDropDownColumn UniqueName="DropDownColumn1" ListTextField="CustomerID" 
            ListValueField="CustomerID" DataSourceID="SqlDataSource1" HeaderText="Dropdown" 
            DropDownControlType="DropDownList"
        </telerik:GridDropDownColumn> 
        <telerik:GridDropDownColumn UniqueName="DropDownColumn2" ListTextField="CustomerID" 
            ListValueField="CustomerID" DataSourceID="SqlDataSource1" HeaderText="Dropdown" 
            DropDownControlType="DropDownList"
        </telerik:GridDropDownColumn> 


    C#:
     
        private void list_SelectedIndexChanged(object sender, System.EventArgs e)  
        {  
            DropDownList dropDown = (DropDownList)sender;  
            GridEditFormItem editForm = (GridEditFormItem)dropDown.NamingContainer;  
            DropDownList dropDown2 = (DropDownList)editForm["DropDownColumn2"].Controls[0];  
            dropDown2.SelectedValue = dropDown.SelectedValue;  
        } 
        private void list_SelectedIndexChanged(object sender, System.EventArgs e) 
        { 
            DropDownList dropDown = (DropDownList)sender; 
            GridEditFormItem editForm = (GridEditFormItem)dropDown.NamingContainer; 
            DropDownList dropDown2 = (DropDownList)editForm["DropDownColumn2"].Controls[0]; 
            dropDown2.SelectedValue = dropDown.SelectedValue; 
        } 


    Regards,
    Princy.
Back to Top