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

Wrong Header Text For Column

1 Answer 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Don
Top achievements
Rank 1
Don asked on 18 Nov 2010, 05:37 PM
In a user control that contains a RadGrid, I am trying to get the header text for the column that is being sorted on. I am doing this in the prerender of the control so all the databinding should have happened already. For some reason the column does not give me the correct text. For some columns the text is changed in the needdatasource event but that should happen before my routine is called. Here is the code. Is there a better way to do this?

private void Set508SortMessage()
{
    if (RadGrid1.MasterTableView.SortExpressions.Count > 0)
    {
        ATSortPane.Visible = AccessibilityMode;
        String msg = GetString("ActionWorklist.SortCriteria.DisplayText.Text");
        String sort = "";
        bool firstTime = true;
        foreach (GridSortExpression gse in RadGrid1.MasterTableView.SortExpressions)
        {
            if (!firstTime)
            {
                sort = sort + ",";
            }
            Common.Framework.SortDirection sd = GetSortDirection(gse.SortOrder);
            sort = string.Format("{0}{1} {2}", sort, RadGrid1.MasterTableView.Columns.FindByDataField(gse.FieldName).HeaderText, sd);
            firstTime = false;
        }
        lbl508Sort.Text = String.Format(msg, sort);
    }
    else
    {
        ATSortPane.Visible = false;
    }
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetoslav
Telerik team
answered on 24 Nov 2010, 07:54 AM
Hello Don,

Try moving your logic to the grid's DataBound event.

Hope it helps.

Regards,
Tsvetoslav
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Don
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or