473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to make the frozen grid view header

The simplest way i follows...........

step 1: place the grid view in a DIV tag...

ie: eg: <div id="divdatagrid" style="overflow: scroll; width: 750px; height: 265px">

Step 2 : on load event call the following java script

<script language="JavaScript" type="text/javascript">
function FreezeGridHeader()
{
var arRows = document.getElementById('ctl00_WorkArea_gvRFPs').r ows;
var oDiv = document.getElementById('divdatagrid');
arRows[0].style.position = "relative";
arRows[0].oParentDiv = oDiv;
arRows[0].style.setExpression("posTop", "oParentDiv.scrollTop-2");
arRows[0].style.zIndex = 30;

}
window.onload=FreezeGridHeader;
</script>

Here "ctl00_WorkArea_gvRFPs" is the gridview name.
"divdatagrid" is the surrounding div name..

Thanks...
@shraf
S.E.... Cochin
May 22 '08 #1
3 4079
Plater
7,872 Expert 4TB
What do you mean by frozen gridview headers? Mine never move already?
May 23 '08 #2
Frinavale
9,735 Expert Mod 8TB
fought with this problem for a while and tried many things like setting the header's position="absolute" etc...etc.

The way I solved this problem was to make a table above the GridView that was static and then placed the GridView into a <div> that allowed scrolling.

Eg:

Expand|Select|Wrap|Line Numbers
  1. <asp:Panel runat="server" ID="Container" style="width:300px">
  2.      <table width="100%" border="0" cellspacing="0">
  3.            <tr><td> <%=FirstColumnHeader%></td></tr>
  4.            <tr><td> <%=SecondColumnHeader%></td></tr>
  5.            <tr><td> <%=ThirdColumnHeader%></td></tr>
  6.      </table>
  7.      <asp:Panel runat="server" ID="Scroll" style="height:100px; overflow:auto;">
  8.           <asp:GridView ID="MyGridView" runat="Server>
  9.             <Columns>
  10.                <asp:BoundField DataField="FirstColumn></asp:BoundField>
  11.                <asp:BoundField DataField="SecondColumn></asp:BoundField>
  12.                <asp:BoundField DataField="ThirdColumn></asp:BoundField>
  13.             </Columns>
  14.            </asp:GridView>
  15.      </asp:Panel><!--Closing the Scrolling area-->
  16. </asp:Panel><!--Closing the Containing area-->
  17.  
The asp code: "<%=FirstColumnHeader%>" prints the value of a property named FirstColumnHeader that returns a string representing the First Column's Header.

Using a table for the header was a little hard to line up with the GridView (the lines were off by a couple of px) but this method avoided problems that occur with setting the GridView's Header to a position of absolute and then scrolling it to the correct position using JavaScript.

-Frinny
May 23 '08 #3
Plater
7,872 Expert 4TB
I still don't know what the situation you are trying to solve here is?
Are you trying to make the gridview header row "float" down when you scroll down?
May 23 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: madhavi | last post by:
Hi > > I have a PV Property When i disable it in form View it works fine > but when i Make a grid View and disable it still i have the flexibility to > Navigate the PV, > > > Please tell me...
1
by: puja | last post by:
hi all, am using grid view in asp.net 2.0 . My problem is easy but can't get it to work. My grid view id = grdContract and am binding grid view using dataset My dataset returns 5 columns from...
0
by: Gian Paolo | last post by:
this is something really i can't find a reason. I have a form with a tabcontrol with tree pages, in the second page there is a Data GRid View. Plus i have a class. When i open the form i...
2
by: probashi | last post by:
Hi, Using the SqlDataSource/SelectParameters/ControlParameter one can easily bind a Grid View with a list box (or any other controls), pretty cool, but my list box is multi select. My...
2
by: Umeshnath | last post by:
Hi, I have placed a grid view inside Atlas panel. On click of a button event, data is populated in the grid view, I want to add scroll bar instead of increasing the size of grid view. I have...
0
by: manojuniverse | last post by:
Hi I have a gridview . I have made the header of gridview fixed by adding a css..as .Fixedheader { position:relative; top: expression(this.parentNode.offsetParent.scrollTop); } But now...
1
sujathaeeshan
by: sujathaeeshan | last post by:
Hi All, I am doing UI design(form design modifications) not programmatically. I am facing problem while appplying font to Data grid column . Here i am placing Data Grid within GroupBox. When...
1
sujathaeeshan
by: sujathaeeshan | last post by:
Hi All, I am doing UI design(form design modifications) not programmatically. I am facing problem while appplying font to Data grid column . Here i am placing Data Grid within GroupBox. When...
0
by: anandmani | last post by:
3) What are the authentications methods are used in the asp.net? 4) What is the use of Master page? How can we incorporate in the application? 5) Can we apply the freeze concept in the Grid...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.