SortCommand and custom headers - why won't they play nice?

Discussion in 'ASP .Net Datagrid Control' started by Nevyn Twyll, Jun 14, 2005.

  1. Nevyn Twyll

    Nevyn Twyll Guest

    I have a datagrid on my webform.
    I am programmatically adding columns to it and hooking it up to a dataset.
    In my ItemDataBound(), I am adding some text and background coloring to the
    Items, and to the Header as well.

    This all works great!

    Now, however, I want to be able to sort the grid by clicking on the column
    headers.

    I set the datagrid.allowsorting = true, wired up my SortCommand(), and it
    basically works, EXCEPT it overwrites the formatting and extra text I put in
    the header cells.
    Is there some way I need to manually put in a hyperlink with a command in
    the header? Can I make a HeaderTemplate in the aspx page that does that,
    and still set the text and coloration manually?

    Thanks for the help!

    - Nevyn
    Nevyn Twyll, Jun 14, 2005
    #1
    1. Advertising

  2. Nevyn Twyll

    Sonu Kapoor Guest

    I did the same some time ago, however with the differecne that I used
    ItemCreated to change the backcolor of the sorted cells. I never had any
    problems with that. You might want to try it in ItemCreated.

    --
    Sonu Kapoor - [MCP]
    ASP.NET Moderator
    WebSite: http://www.Kapoorsolutions.com
    Blog: http://www.Kapoorsolutions.com/blog/
    ASP.NET News: http://www.Kapoorsolutions.com/reblogger/


    "Nevyn Twyll" wrote:

    > I have a datagrid on my webform.
    > I am programmatically adding columns to it and hooking it up to a dataset.
    > In my ItemDataBound(), I am adding some text and background coloring to the
    > Items, and to the Header as well.
    >
    > This all works great!
    >
    > Now, however, I want to be able to sort the grid by clicking on the column
    > headers.
    >
    > I set the datagrid.allowsorting = true, wired up my SortCommand(), and it
    > basically works, EXCEPT it overwrites the formatting and extra text I put in
    > the header cells.
    > Is there some way I need to manually put in a hyperlink with a command in
    > the header? Can I make a HeaderTemplate in the aspx page that does that,
    > and still set the text and coloration manually?
    >
    > Thanks for the help!
    >
    > - Nevyn
    >
    >
    >
    Sonu Kapoor, Jun 14, 2005
    #2
    1. Advertising

  3. Nevyn Twyll

    Nevyn Twyll Guest

    Well, we also need to dynamically set the header text/etc., so I don't know
    that ItemCreated would work - plus, it's still overwriting it, and I would
    think that DataBound() happens later than Created()....

    "Sonu Kapoor" <> wrote in message
    news:...
    >I did the same some time ago, however with the differecne that I used
    > ItemCreated to change the backcolor of the sorted cells. I never had any
    > problems with that. You might want to try it in ItemCreated.
    >
    > --
    > Sonu Kapoor - [MCP]
    > ASP.NET Moderator
    > WebSite: http://www.Kapoorsolutions.com
    > Blog: http://www.Kapoorsolutions.com/blog/
    > ASP.NET News: http://www.Kapoorsolutions.com/reblogger/
    >
    >
    > "Nevyn Twyll" wrote:
    >
    >> I have a datagrid on my webform.
    >> I am programmatically adding columns to it and hooking it up to a
    >> dataset.
    >> In my ItemDataBound(), I am adding some text and background coloring to
    >> the
    >> Items, and to the Header as well.
    >>
    >> This all works great!
    >>
    >> Now, however, I want to be able to sort the grid by clicking on the
    >> column
    >> headers.
    >>
    >> I set the datagrid.allowsorting = true, wired up my SortCommand(), and it
    >> basically works, EXCEPT it overwrites the formatting and extra text I put
    >> in
    >> the header cells.
    >> Is there some way I need to manually put in a hyperlink with a command in
    >> the header? Can I make a HeaderTemplate in the aspx page that does that,
    >> and still set the text and coloration manually?
    >>
    >> Thanks for the help!
    >>
    >> - Nevyn
    >>
    >>
    >>
    Nevyn Twyll, Jun 14, 2005
    #3
  4. Nevyn Twyll

    Sonu Kapoor Guest

    Can you show me the ItemDataBound code and the SortCommand where it
    overwrites the header text?


    --
    Sonu Kapoor - [MCP]
    ASP.NET Moderator
    WebSite: http://www.Kapoorsolutions.com
    Blog: http://www.Kapoorsolutions.com/blog/
    ASP.NET News: http://www.Kapoorsolutions.com/reblogger/


    "Nevyn Twyll" wrote:

    > Well, we also need to dynamically set the header text/etc., so I don't know
    > that ItemCreated would work - plus, it's still overwriting it, and I would
    > think that DataBound() happens later than Created()....
    >
    > "Sonu Kapoor" <> wrote in message
    > news:...
    > >I did the same some time ago, however with the differecne that I used
    > > ItemCreated to change the backcolor of the sorted cells. I never had any
    > > problems with that. You might want to try it in ItemCreated.
    > >
    > > --
    > > Sonu Kapoor - [MCP]
    > > ASP.NET Moderator
    > > WebSite: http://www.Kapoorsolutions.com
    > > Blog: http://www.Kapoorsolutions.com/blog/
    > > ASP.NET News: http://www.Kapoorsolutions.com/reblogger/
    > >
    > >
    > > "Nevyn Twyll" wrote:
    > >
    > >> I have a datagrid on my webform.
    > >> I am programmatically adding columns to it and hooking it up to a
    > >> dataset.
    > >> In my ItemDataBound(), I am adding some text and background coloring to
    > >> the
    > >> Items, and to the Header as well.
    > >>
    > >> This all works great!
    > >>
    > >> Now, however, I want to be able to sort the grid by clicking on the
    > >> column
    > >> headers.
    > >>
    > >> I set the datagrid.allowsorting = true, wired up my SortCommand(), and it
    > >> basically works, EXCEPT it overwrites the formatting and extra text I put
    > >> in
    > >> the header cells.
    > >> Is there some way I need to manually put in a hyperlink with a command in
    > >> the header? Can I make a HeaderTemplate in the aspx page that does that,
    > >> and still set the text and coloration manually?
    > >>
    > >> Thanks for the help!
    > >>
    > >> - Nevyn
    > >>
    > >>
    > >>

    >
    >
    >
    Sonu Kapoor, Jun 15, 2005
    #4
    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. Darrel
    Replies:
    1
    Views:
    321
    Darrel
    May 25, 2006
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,762
    Smokey Grindel
    Dec 2, 2006
  3. Matthew Wilson
    Replies:
    1
    Views:
    392
    John J. Lee
    Oct 22, 2007
  4. Miki
    Replies:
    4
    Views:
    970
    Thomas Bellman
    Oct 14, 2008
  5. Nevyn Twyll

    SortCommand and custom headers - why won't they play nice?

    Nevyn Twyll, Jun 14, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    95
    Sonu Kapoor
    Jun 15, 2005
Loading...

Share This Page