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

Checked change event on GridCheckBoxColumn

3 Answers 949 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jurjen Ladenius
Top achievements
Rank 2
Jurjen Ladenius asked on 09 May 2008, 01:18 PM
Hello,

I have a RadGrid in a control, the grid has a GridCheckBoxColumn. My question is how is it possible to attach a Checked Change event to the column. I tried to convert the column to a checkbox and then to attach the event and PostBack = true. It looks like he does a Postback but doesn't fires the event. Any idea how I could do this?

Thanks,

Jurjen

3 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 10 May 2008, 02:45 PM
Hi Jurjen,

You can use the following code to achieve your goal:

        protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
            {  
                GridEditableItem item = e.Item as GridEditableItem; 
                CheckBox cb = (CheckBox)item["Bool"].Controls[0]; 
                cb.AutoPostBack = true
                cb.CheckedChanged += new System.EventHandler(cb_CheckedChanged); 
            } 
        } 
 
        void cb_CheckedChanged(object sender, System.EventArgs e) 
        { 
            RadAjaxManager1.Alert("checked changed"); 
        } 
 

where "Bool" is the unique name of the check box column as in the first Grid here:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Grid/Examples/GeneralFeatures/ColumnTypes/DefaultCS.aspx

All the best,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Colin
Top achievements
Rank 1
answered on 06 Nov 2012, 12:22 PM
How can I reference other controls in the InsertForm from this event. I have a couple of comboboxes that I want to disable when this is checked?
0
Shinu
Top achievements
Rank 2
answered on 07 Nov 2012, 03:16 AM
Hi Colin,

You can access other controls as follows..

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
     
         GridEditableItem item = e.Item as GridEditableItem;
         CheckBox cb = (CheckBox)item["Bool"].Controls[0];
         cb.AutoPostBack = true;
         cb.CheckedChanged += new System.EventHandler(cb_CheckedChanged);
     }
}
  
void cb_CheckedChanged(object sender, System.EventArgs e)
{
     CheckBox check = (CheckBox)sender;
     GridEditableItem eitem = (GridEditableItem)check.NamingContainer;
     RadComboBox combo = (RadComboBox)eitem.FindControl("RadComboBox1");
     combo.Enabled = false;
}

Thanks,
Shinu.
Tags
Grid
Asked by
Jurjen Ladenius
Top achievements
Rank 2
Answers by
Konstantin Petkov
Telerik team
Colin
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or