We help IT Professionals succeed at work.

Editable Gridview scroll bar

toooki
toooki asked
on
I have this code in ASP.NET VS 2008 C#:

How do I keep the column header outside of the scroll bar in the Gridview? With this code if I scroll down the header row disappears...
Thanks.
<%@ Page Language="C#" .....>
   <style type='text/css'>
  
  .TextBoxGridViewNormal
   {
	border:solid 1px #EEE;
	/*text-align:center;*/	
	width:100%;
	height:100%;
    }
   .TextBoxGridViewEmpty
    {
	border:solid 1px #EEE;
	text-align: center;
	background-color: #CACAFF;	
	width:100%;
	height:100%;
    }      
    </style> 

 <asp:Panel ID="pnltop3" runat="server" Height="300px" style="width:60%;" ScrollBars="Auto">
                <table style="width:100%;">
                    <tr>
                    <td>
                    

                <asp:GridView ID="grd1" runat="server" AllowPaging="False" 
                CellPadding="5" CellSpacing="3" HeaderStyle-CssClass="headerRowGrid" GridLines="None"  
                            BorderWidth="1px" HeaderStyle-Wrap="false"  BorderColor="#EEEEEE"   RowStyle-CssClass="tableEvenRow"
                AlternatingRowStyle-CssClass="tableOddrow"
                AllowSorting="True" AutoGenerateColumns="False"
                <Columns> HeaderText="MyHeader"
.....
.....
 </Columns>

               </asp:GridView>
            

                    </td>
                    </tr>
                </table>
          </asp:Panel>

Open in new window

Comment
Watch Question

Kiran SonawaneProject Lead
BRONZE EXPERT
Top Expert 2011
Commented:
Try this

.
.
.
.
<HeaderStyle CssClass="header"Height="20px" />
</asp:GridView>


Add css header like below

<style type="text/css">

  .header
  {
   font-weight:bold;
    position:absolute;
  }
  </style>
Project Lead
BRONZE EXPERT
Top Expert 2011
Commented:

Author

Commented:
Thank you.
But the example itself does not give a good solution. The header obstruct the first row...Also the width of the header columns do not match with those of the grid columns..overall terrible..

Author

Commented:
Thank you all.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.