Adding Controls To DataGrid Header & Sorting

Discussion in 'ASP .Net Web Controls' started by Neil, Aug 30, 2005.

  1. Neil

    Neil Guest

    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);
    }
    }
     
    Neil, Aug 30, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    1
    Views:
    581
  2. mlt
    Replies:
    2
    Views:
    853
    Jean-Marc Bourguet
    Jan 31, 2009
  3. AlainCD
    Replies:
    0
    Views:
    206
    AlainCD
    Jan 12, 2006
  4. Replies:
    1
    Views:
    336
  5. Sudhir

    Sorting by header in a dynamic datagrid

    Sudhir, Aug 22, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    104
    Sudhir
    Aug 22, 2003
Loading...

Share This Page