Click here to Skip to main content
11,578,241 members (64,037 online)
Click here to Skip to main content

Create a scrollable Gridview in 2.0

, 17 Oct 2006 108K 1.2K 45
Rate this:
Please Sign up or sign in to vote.
Using Javascript's cloneNode to create scrollable Gridview in 2.0

Sample Image - ScrollingGridView.gif


  Using Javascript's cloneNode ,we can clone a table's header,so we can make a gridview to be scrollable.This method isn't set some long css.

  In 2.0's Page_Load event,we must add style for GridView, and this MUST for IE and Firefox can work!

  protected void Page_Load( object sender, EventArgs e )
    if (!IsPostBack)
      GridView1.Attributes.Add("style", "table-layout:fixed");
      GridView1.DataSource = CreateDataSource();

 Next,we must add some javascript for it:

function start()
 var t = document.getElementById("<%=GridView1.ClientID%>");
 var t2 = t.cloneNode(true)
 for(i = t2.rows.length -1;i > 0;i--)
window.onload = start


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Xianhui Meng
Web Developer
China China
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionCode not working in Firefox Pin
Sunnyonfire24-Nov-11 2:43
memberSunnyonfire24-Nov-11 2:43 
Generalnot working for me.. Pin
mayur_mungi3-Jan-10 2:44
membermayur_mungi3-Jan-10 2:44 
GeneralMy vote of 1 Pin
_ShreekUMAr_18-Nov-09 0:47
member_ShreekUMAr_18-Nov-09 0:47 
GeneralOnly works with One Grid per Page Pin
rpeters7420-Mar-09 3:12
memberrpeters7420-Mar-09 3:12 
GeneralRe: Only works with One Grid per Page [modified] Pin
rpeters7420-Mar-09 4:31
memberrpeters7420-Mar-09 4:31 
Generalexcellent... but has a bug when use Themes Pin
jose garcia4-Jan-08 11:00
memberjose garcia4-Jan-08 11:00 
GeneralJust a note on cloning w/ controls. Pin
Xorcist29-Nov-07 6:57
memberXorcist29-Nov-07 6:57 
GeneralExcellent! Could have used this for some time now. Pin
lotsoffear21-Nov-07 5:12
memberlotsoffear21-Nov-07 5:12 
QuestionHow about overflow: scroll instead of overflow-y? Pin
cheepau20-Sep-07 17:11
membercheepau20-Sep-07 17:11 
QuestionHow about fixed column headers? Pin
jmsteward12-Sep-07 7:59
memberjmsteward12-Sep-07 7:59 
AnswerRe: How about fixed column headers? Pin
Sonal_0524-Mar-08 19:31
memberSonal_0524-Mar-08 19:31 
QuestionCool!... but what about styles? Pin
andrez1027-Aug-07 10:26
memberandrez1027-Aug-07 10:26 
QuestionIt WORKS! How about a fixed footer? Pin
GMartinTX17-Apr-07 10:31
memberGMartinTX17-Apr-07 10:31 
AnswerRe: It WORKS! How about a fixed footer? Pin
GMartinTX17-Apr-07 11:13
memberGMartinTX17-Apr-07 11:13 
GeneralDoesn't work on sorting Pin
Umesh_Soni27-Dec-06 18:17
memberUmesh_Soni27-Dec-06 18:17 
GeneralRe: Doesn't work on sorting Pin
topdrog17-Jun-07 12:21
membertopdrog17-Jun-07 12:21 
QuestionDoesn't work in firefox :( Pin
Gökmen BULUT13-Nov-06 22:49
memberGökmen BULUT13-Nov-06 22:49 
AnswerRe: Doesn't work in firefox :( Pin
lotsoffear21-Nov-07 5:04
memberlotsoffear21-Nov-07 5:04 
Generalworks fine as soon as I put change in the correct place great job thanks Pin
lennys3-Nov-06 11:35
memberlennys3-Nov-06 11:35 
Generaltried your suggestion still fails Pin
lennys3-Nov-06 10:43
memberlennys3-Nov-06 10:43 
Generaldoesn't work for me Pin
kunalagrawal20-Oct-06 9:07
memberkunalagrawal20-Oct-06 9:07 
AnswerRe: doesn't work for me Pin
Xianhui Meng20-Oct-06 16:45
memberXianhui Meng20-Oct-06 16:45 
GeneralRe: doesn't work for me Pin
kunalagrawal23-Oct-06 7:30
memberkunalagrawal23-Oct-06 7:30 
GeneralRe: doesn't work for me Pin
Sasha Shipka20-Nov-06 2:05
memberSasha Shipka20-Nov-06 2:05 
GeneralRe: doesn't work for me Pin
jason2k28-Oct-06 15:33
memberjason2k28-Oct-06 15:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150603.1 | Last Updated 17 Oct 2006
Article Copyright 2006 by Xianhui Meng
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid