More Group Sites
Education Books
School Rankings
Jobless Net
Better Home

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



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

Rank: Administration


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

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>:


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

Rss Feed  Atom Feed
Users browsing this topic
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.