Member 13174280
it is not enough to change the key to have another GridView
First call -- work
ScriptManager.RegisterStartupScript(Page, this.GetType(), "Grd2", "<script>MakeStaticHeader('" + GridView2.ClientID + "', 450, 850 , 22 ,false); </script>", false);
other GridView with the new Key -- variable already decalred
ScriptManager.RegisterStartupScript(Page, this.GetType(), "Grd1", "<script>MakeStaticHeader('" + GridView1.ClientID + "', 250, 550 , 22 ,false); </script>", false);
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');
var DivFR = document.getElementById('DivFooterRow');
.........
Structure for a Grid
<%-- root --%>
<div style="text-align:left;" id="DivRoot">
<div style="overflow: hidden;" id="DivHeaderRow">
</div>
<%-- scroll --%>
<div style="overflow:scroll;" onscroll="OnScrollDiv(this)" id="DivMainContent">
<asp:GridView ID="GridView2" runat="server" Width="100%" BorderWidth="1px" AutoGenerateColumns="False" BackColor="gray" ForeColor="white" ShowFooter="false">
<Columns>
..........
</Columns>
</asp:GridView>
</div>
<%-- footer --%>
<div id="DivFooterRow" style="overflow:hidden">
</div>
</div>
for Other Grid on the same page DivRoot, DivMainContent, DivFooterRow are already declared
<%-- root --%>
<div style="text-align:left;" id="DivRoot">
<div style="overflow: hidden;" id="DivHeaderRow">
</div>
<%-- scroll --%>
<div style="overflow:scroll;" onscroll="OnScrollDiv(this)" id="DivMainContent">
<asp:GridView ID="GridView1" runat="server" Width="100%" BorderWidth="1px" AutoGenerateColumns="False" BackColor="gray" ForeColor="white" ShowFooter="false">
<Columns>
..........
</Columns>
</asp:GridView>
</div>
<%-- footer --%>
<div id="DivFooterRow" style="overflow:hidden">
</div>
</div>