如何将 jquery tablesorter 与 asp.net gridview 一起使用? [英] How can I use jquery tablesorter with an asp.net gridview?
本文介绍了如何将 jquery tablesorter 与 asp.net gridview 一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 tablesorter 插件添加对 gridview 的排序.
I'm trying to add sorting of a gridview using the tablesorter plugin.
然而,gridview 不会呈现 THEAD 和 TBODY 标签.有没有办法让它添加它们?
However, the gridview does not render the THEAD and TBODY tags. Is there a way to get it to add them?
推荐答案
来源:http://justgeeks.blogspot.com/2008/09/add-tbody-and-thead-to-gridview.html
查看
<asp:GridView ID="GridView1" runat="server"
OnPreRender="GridView1_PreRender">
</asp:GridView>
cs
protected void GridView1_PreRender(object sender, EventArgs e)
{
// You only need the following 2 lines of code if you are not
// using an ObjectDataSource of SqlDataSource
GridView1.DataSource = Sample.GetData();
GridView1.DataBind();
if (GridView1.Rows.Count > 0)
{
//This replaces <td> with <th> and adds the scope attribute
GridView1.UseAccessibleHeader = true;
//This will add the <thead> and <tbody> elements
GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
//This adds the <tfoot> element.
//Remove if you don't have a footer row
GridView1.FooterRow.TableSection = TableRowSection.TableFooter;
}
}
希望对您有所帮助!
这篇关于如何将 jquery tablesorter 与 asp.net gridview 一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文