Wednesday, December 28, 2011

How to handle RadGrid's Select Column Checkbox Event

Do these steps to handle the Radgrid's select column checkbox event.

1. Allow row selection

<ClientSettings ...>
                        <Selecting AllowRowSelect="true" />

2. Place the select column/row checkbox
<telerik:RadGrid ...>
<ClientSettings ...>...</ClientSettings>

       <telerik:GridClientSelectColumn UniqueName="Selectcol" HeaderText="select">

3. Specify the ItemCreated Event

4. Define ItemCreated Event
protected void  RadGrid_ItemCreated(object sender, GridItemEventArgs e)
        GridHeaderItem HeaderItem;
        GridDataItem DateItem;
        CheckBox chkbx=new CheckBox();
        if (e.Item is GridHeaderItem)
            HeaderItem = (GridHeaderItem)e.Item;
            chkbx = (CheckBox)HeaderItem["SelectCol"].Controls[0];
        if (e.Item is GridDataItem)
            DateItem = (GridDataItem)e.Item;
            chkbx = (CheckBox)DateItem["SelectCol"].Controls[0];
        chkbx.AutoPostBack = true;
        chkbx.CheckedChanged += new EventHandler(chkbx_CheckedChanged);
5. Define chkbx_CheckedChanged

void chkbx_CheckedChanged(object sender, EventArgs e)



Anonymous said...

I found this useful. I was able to isolate the header checkbox click into a server side event with this. With this, I could update a label with the selected items count when the header checkbox is clicked.

Anonymous said...

awesome, i burned hours today trying to figure this out before stumbling upon your page. 2 minutes later it works. Thanks!

Adeel Nasir said...

Good. Sorry for late reply 😊

Adeel Nasir said...

Good, sorry for late reply