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

Loading a radgrid & altering components

1 Answer 24 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 22 Aug 2010, 07:22 PM

Hi everyone,

 I have a radgrid with 3 checkboxes on it. When it loads it has many rows. For some of the rows the check boxes are enabled and for other they are disabled. 

 My problem is though I don't know where to put the intelligence that determines this. That is, I don't know what event to use Load, init, something else (render perhaps)? I need the user to be able to be able to see it every time the the page loads and when they postback.

 I would appreciate any advice/suggestions/simple code-samples that you may be able to offer.

Cheers,
Al.

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 25 Aug 2010, 09:23 AM
Hi Alan,

If the checkbox state depends on some data inside the table row, then the correct place to put the "intelligence" is ItemDataBound. If the data inside the table row does not matter, then you can use ItemCreated.

http://www.telerik.com/help/aspnet-ajax/telerik.web.ui-telerik.web.ui.radgrid-itemdatabound_ev.html

http://www.telerik.com/help/aspnet-ajax/grdeventsequence.html

http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html

http://www.telerik.com/help/aspnet-ajax/grdconditionalformatting.html


For example

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = e.Item as GridDataItem;
        CheckBox chk = item["ColumnUniqueNameHere"].Controls[0] as CheckBox;
        if (true)
            chk.Enabled = true;
        else
            chk.Enabled = false;
    }
}


Kind regards,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Alan
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or