N
Neil
Hi,
I'm building a custom version of the DataGrid control, I want this control
to sort and display an indication to the user of the sort direction. I've
seen examples of adding a label control to the header item using the
OnItemCreated event. I've followed the example
http://www.msdn.microsoft.com/msdnmag/issues/01/10/cutting/default.aspx
but now I have a problem. After the first sort the sort expression in the
sort event is reported as the column to the right of the actual one I
clicked. I can see from hovering over the column heading that the postback
is reporting column 1 as ctl1in the dopostback code, this should be ctl0 and
seems to be causing an issue.
This only happens when I add a label control to the header cell using the
following code.
for(int i=0; i < Columns.Count; i++)
{
if(sortExpr == Columns.SortExpression)
{
TableCell cell = e.Item.Cells;
Label sortedLbl = new Label();
sortedLbl.Font.Name = "Webdings";
sortedLbl.Font.Size = FontUnit.XSmall;
sortedLbl.Text = symbolText;
cell.Controls.Add(sortedLbl);
}
}
I'm building a custom version of the DataGrid control, I want this control
to sort and display an indication to the user of the sort direction. I've
seen examples of adding a label control to the header item using the
OnItemCreated event. I've followed the example
http://www.msdn.microsoft.com/msdnmag/issues/01/10/cutting/default.aspx
but now I have a problem. After the first sort the sort expression in the
sort event is reported as the column to the right of the actual one I
clicked. I can see from hovering over the column heading that the postback
is reporting column 1 as ctl1in the dopostback code, this should be ctl0 and
seems to be causing an issue.
This only happens when I add a label control to the header cell using the
following code.
for(int i=0; i < Columns.Count; i++)
{
if(sortExpr == Columns.SortExpression)
{
TableCell cell = e.Item.Cells;
Label sortedLbl = new Label();
sortedLbl.Font.Name = "Webdings";
sortedLbl.Font.Size = FontUnit.XSmall;
sortedLbl.Text = symbolText;
cell.Controls.Add(sortedLbl);
}
}