Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

How to fix DataGrid Header with ,

I tried many ways not working as expected, please suggest me the ways how to make DataGrid with fixed header,
Posted

Put the Header and Gridview in two seprate div having same width like below
<div style=" background-color:Green;  <br mode=" hold=" />        height:30px;width:600px; margin:0;padding:0">
       <table cellspacing="0" cellpadding="0" rules="all" border="1" id="tblHeader">
        style="font-family:Arial;font-size:10pt;width:600px;color:white;
        border-collapse:collapse;height:100%;">
           <tr>
              <td style="width:150px;text-align:center">CustomerID</td>
              <td style="width:150px;text-align:center">City</td>
              <td style="width:150px;text-align:center">Country</td>
              <td style="width:150px;text-align:center">PostalCode</td>
           </tr>
       </table>
       </div>
       <div style="height:200px; width:600px; overflow:auto;">
       <asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown">
           AutoGenerateColumns = "false" Font-Names = "Arial" ShowHeader = "false"
           Font-Size = "11pt" AlternatingRowStyle-BackColor = "#C2D69B" >
          <columns>
           <asp:boundfield itemstyle-width="150px" datafield="CustomerID" />
           <asp:boundfield itemstyle-width="150px" datafield="City" />
           <asp:boundfield itemstyle-width="150px" datafield="Country" />
           <asp:boundfield itemstyle-width="150px" datafield="PostalCode" />
          </columns>
       </asp:gridview>
       </div>
 
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