I\'m trying to add sorting of a gridview using the tablesorter plugin.
However, the gridview does not render the THEAD and TBODY tags. Is there a way to get it to a
Try this :
protected void grdDtls_DataBound(object sender, EventArgs e)
{
if (grdDtls.Rows.Count > 0)
{
//To render header in accessible format
grdDtls.UseAccessibleHeader = true;
//Add the element
grdDtls.HeaderRow.TableSection = TableRowSection.TableHeader;
//Add the element
grdDtls.FooterRow.TableSection = TableRowSection.TableFooter;
if (grdDtls.TopPagerRow != null)
{
grdDtls.TopPagerRow.TableSection = TableRowSection.TableHeader;
}
if (grdDtls.BottomPagerRow != null)
{
grdDtls.BottomPagerRow.TableSection = TableRowSection.TableFooter;
}
}
}
and use following code wherever you fill your grid.
ScriptManager.RegisterStartupScript(this, GetType(), "SortGrid", string.Format("$(function(){{$('#{0}').tablesorter(); }});", grdDtls.ClientID), true);
- 热议问题