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;
}
}