How can I use jquery tablesorter with an asp.net gridview?

后端 未结 2 597
Happy的楠姐
Happy的楠姐 2021-01-07 10:42

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

2条回答
  •  一向
    一向 (楼主)
    2021-01-07 10:58

    Source: http://justgeeks.blogspot.com/2008/09/add-tbody-and-thead-to-gridview.html

    view

    
    
    

    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  with  and adds the scope attribute
          GridView1.UseAccessibleHeader = true;
    
          //This will add the  and  elements
          GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;
    
          //This adds the  element. 
          //Remove if you don't have a footer row
          GridView1.FooterRow.TableSection = TableRowSection.TableFooter;
       }
    
    }
    

    I hope this help!

提交回复
热议问题