views:

293

answers:

1

Hi,

I want to use Christian Bach's tableSorter client-side table sorting jQuery plugin with my asp.Net GridView control.

But the problem is, in the documentation it writes:

tablesorter works on standard HTML tables. You must include THEAD and TBODY tags:

And unfortunately asp.net renders my GridView only with tags and header row stays within as the 1st row.

I have tried:

   dgvRate.HeaderRow.TableSection = TableRowSection.TableHeader;

after calling .DataBind();

It only helped to have <TH></TH> within the header . But still everything is inside <tbody>

Can I accomplish this, I mean moving my 1st row from <tbody></tbody> to <thead></thead> ?

I do not want to add it manually on PreRender stage; I am sure this could be handled much simpler, isn't it?

thanks

+1  A: 

Sometimes you have to give it an accessible class to get this to trigger, like this:

protected void Page_Load(object sender, EventArgs e) 
{
  dgvRate.UseAccessibleHeader = true;
  dgvRate.HeaderRow.TableSection = TableRowSection.TableHeader;
  dgvRate.HeaderRow.CssClass = "headerclass";
}

Though, for consistency in behavior in all cases I would go the PreRender route.

Nick Craver
It does not work with my gridView. Maybe bcoz I create my GridView columns dynamicaly on the code-behind. (I have tried your suggestion on a simple asp.net GridView and I confirm that it works there)
burak ozdogan
@burak - Yes, adjusting the columns dynamically fires a lot of events, are you setting this after manipulating the columns for the last time?
Nick Craver
Perfect! I have moved this to OnPrerender and it worked.thank you very much!
burak ozdogan