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

Issue with cell conditional formatting and sorting

1 Answer 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ron
Top achievements
Rank 1
Ron asked on 28 Mar 2011, 05:33 PM
Hi

I am using the ASP.Net Ajax RadGrid control in a new web application. For this grid I need to apply conditional cell formatting while user should be able to sort the grid. The example I found in RadGrid documentation (http://www.telerik.com/help/aspnet-ajax/grid-appearance-conditional-formatting.html) works using ItemDataBound event hanlder but only when the grid loads firs time but as soon as I click on a column header to sort a column, grid loads with new set of data without calling ItemDataBound even handler and cells lose their formatting.

I hook up the ItemDataBound event handler in Page_Load as below:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        SummaryGrid.ItemDataBound +=new GridItemEventHandler(SummaryGrid_ItemDataBound);
        ...
    }
}


Is there another way to keep the conditional formatting while allowing to sort, group, etc.?

I appreciate your help in advance.
Thanks
Ron Farko

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 29 Mar 2011, 01:40 PM
Hello Ron,

You have to re-attach the event handler on each postback.
protected void Page_Load(object sender, EventArgs e)
{   
    if (!IsPostBack)
    {       
        ...
    }
    SummaryGrid.ItemDataBound +=new GridItemEventHandler(SummaryGrid_ItemDataBound);
}


Let me know if you need further assistance.

Kind regards,
Daniel
the Telerik team
Tags
Grid
Asked by
Ron
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or