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

GridDropDownColumn AutoPostback on SelectedIndex Change

1 Answer 300 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 05 Mar 2010, 04:24 PM
I have a RadGrid that is setup to use the InLine edit mode.  He is snippet of code containing the GridDropDownColumn.

<telerik:GridDropDownColumn DataField="BreakTypCd" ListDataMember="BreakTyp" 
                            HeaderText="Break Type" ListTextField="Descript" ListValueField="BreakTypCd" 
                            UniqueName="BreakTyp" ColumnEditorID="GridDropDownColumnEditor1">  
</telerik:GridDropDownColumn> 

When I enter Edit mode, I would like a SelectedIndex event fired.  This will allow me to update other item on the row.  I don't see any events in the GridDropDownColumn properties list.

Any thoughts on how I get an event to fire?

Thanks.

Steve

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Mar 2010, 06:41 AM
Hi,

You can access the Dropdownlist of the GridDropdownColumn in the edit mode in the ItemCreated event  and  attach the SelectedIndexChanged event as shown below:

C#
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
        {  
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
            {                 
                DropDownList list = (e.Item as GridEditableItem)["DropDownColumn1"].Controls[0] as DropDownList;  
  
                //attach SelectedIndexChanged event for the dropdown control  
                list.AutoPostBack = true;  
                list.SelectedIndexChanged += new EventHandler(list_SelectedIndexChanged);  
            }  
        }  
  
        void list_SelectedIndexChanged(object sender, EventArgs e)  
        {  
            //first reference the edited grid item through the NamingContainer                                                     attribute  
            GridEditableItem editedItem = (sender as DropDownList).NamingContainer as GridEditableItem;  
                        
                        
             
        }  

Hope this helps.

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