I did this dynamic header through
protected void GridView1_RowCreated(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[5].Text =
myDropDownList.SelectedValue;
}
}
In the declaration of this GridView, I have
AllowSorting="true"
and of course I have a Sorting event handler.
Every column is sortable except this column with the dynamic header.
If assign a static value to this header and remove this RowCreated
event handler, this column becomes sortable, too.
So, the question is: How can I make the column with a dynamic header
sortable?
If you also need paging, you will have to write custom software to do this
and will probably have to retrieve the data each time there is a sort so you
can get a pointer to figure out start and end of the page.
If you want to see how Microsoft does it, you can use Reflector on the .NET
assemblies or, in VS 2008, step into the code. Both can give you a clue of
how MS accomplishes sorting.
Here's a couple of articles:
http://lakshmik.blogspot.com/2006/06/aspnet-20-custom-paging-and-custom.html
http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=428
I am kind of fond of the idea in the second one, although I have not tried
it. Binding with generics would take a bit of work to massage the data
intitially, but the benefits outweigh the extra work.
--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss
or just read it:
http://gregorybeamer.spaces.live.com/
*************************************************
| Think outside the box!
|
*************************************************
"gnewsgroup" <gnews...@gmail.com> wrote in message
news:67c552e2-ed82-4b90...@m36g2000hse.googlegroups.com...
Thank you very much for the references. The problem for me right now
is that the dynamically created header isn't even clickable, unlike
other static header, which you can click and sort.