Home All Groups Group Topic Archive Search About

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

Author
14 Jun 2005 4:53 PM
Nevyn Twyll
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

Author
14 Jun 2005 6:10 PM
Sonu Kapoor
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.

Show quoteHide quote
"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
>
>
>
Author
14 Jun 2005 10:29 PM
Nevyn Twyll
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()....

Show quoteHide quote
"Sonu Kapoor" <SonuKap***@discussions.microsoft.com> wrote in message
news:C33547BE-4DAB-4E2E-B60F-25FB791D2F36@microsoft.com...
>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
>>
>>
>>
Author
14 Jun 2005 11:15 PM
Sonu Kapoor
Can you show me the ItemDataBound code and the SortCommand where it
overwrites the header text?


Show quoteHide quote
"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" <SonuKap***@discussions.microsoft.com> wrote in message
> news:C33547BE-4DAB-4E2E-B60F-25FB791D2F36@microsoft.com...
> >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
> >>
> >>
> >>
>
>
>