Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
freeZe gridview header in asp.net using firefox my gridview header is fixd in ie8 but same script not wrok in firefox
.FrozenHeader
       {
         background-color:Gray;
           position: relative;
           cursor: default;
           top:auto;
           z-index: 10;
          top:expression(this.parentNode.parentNode.parentNode.scrollTop-1);
       }

any solution for firefox?
Posted
Updated 9-Aug-11 2:38am
v4
Comments
Herman<T>.Instance 9-Aug-11 8:22am    
I guess this is not a question?
What is your exact problem?

XML
<style type="text/css">
    .WrapperDiv {
        width:800px;height:400px;border: 1px solid black;
    }
    .WrapperDiv TH {
        position:relative;
    }
    .WrapperDiv TR
    {
        /* Needed for IE */
        height:0px;
    }
</style>
<script>
    function onLoad()
    {
        FreezeGridViewHeader('GridView1','WrapperDiv');
    }


    function FreezeGridViewHeader(gridID,wrapperDivCssClass)
    {
        /// <summary>
        ///   Used to create a fixed GridView header and allow scrolling
        /// </summary>
        /// <param name="gridID" type="String">
        ///   Client-side ID of the GridView control
        /// </param>
        /// <param name="wrapperDivCssClass" type="String">
        ///   CSS class to be applied to the GridView's wrapper div element.
        ///   Class MUST specify the CSS height and width properties.
        ///   Example: width:800px;height:400px;border:1px solid black;
        /// </param>
        var grid = document.getElementById(gridID);
        if (grid != 'undefined')
        {
            grid.style.visibility = 'hidden';
            var div = null;
            if (grid.parentNode != 'undefined')
            {
                //Find wrapper div output by GridView
                div = grid.parentNode;
                if (div.tagName == "DIV")
                {
                    div.className = wrapperDivCssClass;
                    div.style.overflow = "auto";
                }
            }
            //Find DOM TBODY element and remove first TR tag from
            //it and add to a THEAD element instead so CSS styles
            //can be applied properly in both IE and FireFox
            var tags = grid.getElementsByTagName('TBODY');
            if (tags != 'undefined')
            {
                var tbody = tags[0];
                var trs = tbody.getElementsByTagName('TR');
                var headerHeight = 8;
                if (trs != 'undefined')
                {
                    headerHeight += trs[0].offsetHeight;
                    var headTR = tbody.removeChild(trs[0]);
                    var head = document.createElement('THEAD');
                    head.appendChild(headTR);
                    grid.insertBefore(head, grid.firstChild);
                }
                //Needed for Firefox
                tbody.style.height =
                  (div.offsetHeight -  headerHeight) + 'px';
                tbody.style.overflowX = "hidden";
                tbody.overflow = 'auto';
                tbody.overflowX = 'hidden';
            }
            grid.style.visibility = 'visible';
        }
    }
</script>
 
Share this answer
 
Comments
onpavan 9-Aug-11 8:34am    
my gridview header is fixd in ie8 but same script not wrok in firefox
.FrozenHeader
{
background-color:Gray;
position: relative;
cursor: default;
top:auto;
z-index: 10;
top:expression(this.parentNode.parentNode.parentNode.scrollTop-1);

}

any solution for firefox
Already answered for similar question long time ago

Freeze grid in asp.net[^]

You can find more here[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900