DataGrid strange behaviour

Discussion in 'ASP .Net' started by Stefano Mostarda, Apr 24, 2004.

  1. Hi there,

    I have a problem.

    I've a grid where sort is enabled.

    I've handled the datagrid itemcreated event. In the code I add a bitmap
    to the header of the column selected by the user.
    Here's the code:

    int i;
    System.Web.UI.WebControls.Image imSortBitmap

    if (e.Item.ItemType == ListItemType.Header){
    for (i=0; i<grUser.Columns.Count; i++){
    if (FSortExpressions == grUser.Columns.SortExpression){
    imSortBitmap = new System.Web.UI.WebControls.Image();
    imSortBitmap.ImageUrl = "images/" + ((stUserSearchField.SortOrder
    == "DESC") ? "SortDesc.Gif" : "SortAsc.Gif");
    e.Item.Cells.CssClass = "SelectedHeader";
    e.Item.Cells.Controls.Add(imSortBitmap);
    }
    else{
    grUser.Columns.HeaderStyle.CssClass = "Header";
    }
    }
    }

    I've handled the datagrid sortcommand event.
    Here's the code

    BindGrid(Convert.ToString(e.SortExpression));

    The problem is that in the sortcommand event the e.SortExpression return
    the sort expression of the column next to the one the user has selected.
    If I comment the line which adds the bitmap to the cell in the
    itemcreated event everything works fine.

    Any ideas?

    Thanks in advance
    Stefano Mostarda MCP
    Rome Italy
    Stefano Mostarda, Apr 24, 2004
    #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. Antonio

    Strange encoding behaviour

    Antonio, Dec 29, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    422
    Antonio
    Dec 29, 2004
  2. Jan
    Replies:
    2
    Views:
    1,426
    Mike Treseler
    Dec 16, 2004
  3. David Cantin

    Strange behaviour with perl and apache

    David Cantin, Nov 3, 2003, in forum: Perl
    Replies:
    1
    Views:
    453
    Jim Gibson
    Nov 3, 2003
  4. Dennis Johansson
    Replies:
    1
    Views:
    499
    Dennis Johansson
    Aug 21, 2003
  5. Andy Chambers
    Replies:
    1
    Views:
    383
    Daniel Dyer
    May 14, 2007
Loading...

Share This Page