473,568 Members | 2,939 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make the frozen grid view header

36 New Member
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="JavaS cript" type="text/javascript">
function FreezeGridHeade r()
{
var arRows = document.getEle mentById('ctl00 _WorkArea_gvRFP s').rows;
var oDiv = document.getEle mentById('divda tagrid');
arRows[0].style.position = "relative";
arRows[0].oParentDiv = oDiv;
arRows[0].style.setExpre ssion("posTop", "oParentDiv.scr ollTop-2");
arRows[0].style.zIndex = 30;

}
window.onload=F reezeGridHeader ;
</script>

Here "ctl00_WorkArea _gvRFPs" is the gridview name.
"divdatagri d" is the surrounding div name..

Thanks...
@shraf
S.E.... Cochin
May 22 '08 #1
3 4088
Plater
7,872 Recognized Expert Expert
What do you mean by frozen gridview headers? Mine never move already?
May 23 '08 #2
Frinavale
9,735 Recognized Expert Moderator Expert
fought with this problem for a while and tried many things like setting the header's position="absol ute" 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: "<%=FirstColumn Header%>" prints the value of a property named FirstColumnHead er 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 Recognized Expert Expert
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
979
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 how to restrict navigation to PV Property when in Grid Mode >
1
2742
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 sql database and I have auto generate columns = true for grdContract grdContract.DataSource = ........dataset returned by a function
0
4156
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 "inizialize" the Data Grid View (add a data sorce, filled with notthing at staratup, and hide some columns) when i put a code in the txtCLCOD textbox start a...
2
4076
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 questions is, how can I bind a Grid View Control to a multi select list box (or any multi values controls) Thanks
2
3844
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 written the following code. <div id="Layer1" style="width:350px; height:140px; z-index:1;overflow-y: scroll"> But the problem was scroll bar will...
0
1215
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 when I resize the window .Gridview header remains at same place at which it was ealier. Header doesnot resize itself..
1
2124
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 i apply the Group box text font as Arial and bold this formatting applies to all controls which is placed inside the group box. But when i try to...
1
1662
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 i apply the Group box text font as Arial and bold this formatting applies to all controls which is placed inside the group box. But when i try to...
0
1166
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 View? If it is possible how u can freeze the header row in the Grid view?
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
932
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.