More Group Sites
Education Books
School Rankings
Jobless Net
Better Home
Enviro++
更好教育论坛


Help | Subscribe/Unsubscribe | Rules | Other Group Sites: Better Education | Better Education Forum
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post Go to first unread
hong  
#1 Posted : Saturday, 29 August 2015 10:58:46 PM(UTC)
hong

Rank: Administration

Reputation:

Groups: AcademicCoachingSchool, admin, Administration, BookSeller, CatholicSchool, CoachingAdult, CoachingProfessional, CoachingSports, ExtraCurriculumCoaching, IndependentSchool, Moderator, MusicTeacher, PrivateSchool, PublicSchool, SelectiveSchool, tutor
Joined: 23/11/2008(UTC)
Posts: 519

I wanted to reuse JQuery datatable styling and functionalities for ASP.NET GridView by integrating datatables.js with Gridview. Unlike repeater and ListView, GridView doesn't generate thead and tbody tags when it is rendered as html. The header and body groups are required by the datatable, hence caused datatables.js to fail.

To render th, use the default UseAccessibleHeader="True" of GridView. UseAccessibleHeaders makes it put <th> instead of <td>. It means it's a header cell rather than a standard cell.

To make GridView generate <thead>, <th> and <tbody>:

Code:

GridView1.UseAccessibleHeader = true;
GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;


The HeaderRow property will be null until the GridView has been data bound, so make sure to wait until data binding has occurred before running the above line of code. So we cannot put the code in Page_Load(). Otherwise we will get NullReferenceException.

If you do the data binding in GridView1_PreRender(), place the above code here after GridView1.DataBind();

Edited by user Sunday, 30 August 2015 11:15:08 AM(UTC)  | Reason: Not specified

Sponsor
Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.