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

N

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
 
N

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()....

Sonu Kapoor said:
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 said:
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
 
S

Sonu Kapoor

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 said:
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 said:
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 said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top