Fixed headers in gridview with out plugin in Asp.net

  <script>                
                    function MakeStaticHeader(gridId, height, width, headerHeight, isFooter) {

                        var tbl = document.getElementById(gridId);
                        if (tbl) {
                            var DivHR = document.getElementById('DivHeaderRow');
                            var DivMC = document.getElementById('DivMainContent');

                            //*** Set divheaderRow Properties ****
                            DivHR.style.height = headerHeight + 'px';
                            DivHR.style.width = (parseInt(width) - 10) + 'px';
                            DivHR.style.position = 'relative';
                            DivHR.style.top = '0px';
                            DivHR.style.zIndex = '10';
                            DivHR.style.verticalAlign = 'top';

                            //*** Set divMainContent Properties ****
                            DivMC.style.width = width + 'px';
                            DivMC.style.height = height + 'px';
                            DivMC.style.position = 'relative';
                            DivMC.style.top = -headerHeight + 'px';
                            DivMC.style.zIndex = '1';

                            //****Copy Header in divHeaderRow****
                            DivHR.appendChild(tbl.cloneNode(true));
                        }
                        setEmpCode('1');
                    }

                    function OnScrollDiv(Scrollablediv) {
                        document.getElementById('DivHeaderRow').scrollLeft = Scrollablediv.scrollLeft;
                        // document.getElementById('DivFooterRow').scrollLeft = Scrollablediv.scrollLeft;
                    }
                    function setEmpCode(obj) {
                        if (obj != '1') {
                            var row = obj.parentNode.parentNode;
                            var rowIndex = row.rowIndex - 1;
                            //alert(document.getElementById('MainContent_gvAssetDetails_txtempcode_' + rowIndex));
                            document.getElementById('MainContent_gvAssetDetails_txtempcode_' + rowIndex).value = obj.value;
                            //alert(document.getElementById('MainContent_gvAssetDetails_txtempcode_' + rowIndex).value);
                        }
                    }

                </script>
 <asp:GridView ID="gvAssetDetails" runat="server" />



===>> in c# code::::;
---------------------------------------
 ScriptManager.RegisterStartupScript(Page, this.GetType(), "Key", "<script>MakeStaticHeader('" + gvAssetDetails.ClientID + "', 400 ,1350, 40 ,true); </script>", false);
             

Comments

Popular posts from this blog

How to write Pure java script Program?