0% found this document useful (0 votes)
75 views

How To Freez Grid View Header

This document provides steps to freeze column headers in an ASP.NET GridView using two different approaches: 1. Using the CoolControl third-party library, which allows fixing column headers, footers, and pagers. 2. Using CSS positioning properties to fix the header row at the top while allowing the body to scroll.

Uploaded by

sathishreddymca
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views

How To Freez Grid View Header

This document provides steps to freeze column headers in an ASP.NET GridView using two different approaches: 1. Using the CoolControl third-party library, which allows fixing column headers, footers, and pagers. 2. Using CSS positioning properties to fix the header row at the top while allowing the body to scroll.

Uploaded by

sathishreddymca
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 5

Freez Column header Using CoolControl

Step 1 : Download CoolControl dll From Link:- http://ideasparks.codeplex.com/

Step 2:
1. Go to new website in visual studio ,
2. Open ToolBox
Add new tab -> Choose items ->Brouse the path of CoolControl.dll
3. Drag and Drop CoolGridview in your Project->

Note:
CoolGridview also supports all Events, Properties and Classes of Asp Gridview

Step 3: Sample Code

<cc1:CoolGridView ID="gdvgridScrollTrail" runat="server" PageSize ="25"


AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
BackColor="White" BorderStyle="None" EmptyDataText="No Records
Found." UseAccessibleHeader ="false"
Height="400px" Width ="400px"
OnSorting ="gdvgridScrollTrail_Sorting_Click"
AutoGenerateSelectButton ="true"
OnPageIndexChanging
="gdvgridScrollTrail_OnPageIndexChanging_Click"
OnRowCreated ="gdvgridScrollTrail_RowCreated"
onselectedindexchanged="gdvgridScrollTrail_SelectedIndexChanged">
<PagerSettings Position="Bottom" Mode ="NumericFirstLast"/>
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />

<Columns>
<asp:BoundField DataField="Branch" HeaderText="Branch"
SortExpression="Branch" />
<asp:BoundField DataField="Department_Name"
HeaderText="Department"
SortExpression="Department_Name" />
<asp:BoundField DataField="DoctorName" HeaderText="Doctor
Name"
SortExpression="DoctorName" />
<asp:BoundField DataField="AvailabilityStatus"
HeaderText="Generel Availability"
SortExpression="AvailabilityStatus" />
</Columns>
<RowStyle CssClass="gridheadsub02" />
<HeaderStyle CssClass="gridhead" />
<AlternatingRowStyle CssClass="gridheadsub01" />

</cc1:CoolGridView>

Note :

coolgridview having extra property called

AllowResizeColumn -To Resize the Column Width at runtime

Eg;AllowResizeColumn ="true"

Step 4:
1. Add Datasource to Coolgridview
2. Run the project.

ADDITIONAL FEATURES OF COOLGRIDVIEW COMPARE TO ASP GRIDVIEW


1. Display fix column headers, footer and pager
2. Supports scrollable content
3. User-resizeable column widths
4. Maintains scroll position and column widths after a postback or callback

Freez Column header Using Css

Step 1: Open New Aspx Page

Step 2: Add CSS Properties


Position: Relative;

Eg:
.gridheadUsingcss
{
position :relative ;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
color: #000;
background-color: #EAA874;
width: 100%;
text-align:left;
background-position: center;
padding-top:2px;
}

Step 3: Drag and Drop Aspx Gridview

1 : In Header-Style Property Add Call CSS

Eg:

<div style="overflow:scroll; border:1px; height:400px; width :315px;


border-style:solid; border-color:Blue;" >

<asp:GridView ID="gdvFreazHeaderCss" runat="server" PageSize


="25"
AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
BackColor="White" BorderStyle="None" EmptyDataText="No Records
Found." UseAccessibleHeader ="false"
Width ="300px"
OnSorting ="gdvgridScrollTrail_Sorting_Click"
AutoGenerateSelectButton ="true"
OnPageIndexChanging
="gdvgridScrollTrail_OnPageIndexChanging_Click"
OnRowCreated ="gdvgridScrollTrail_RowCreated">
<PagerSettings Position="TopAndBottom" />
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<Columns>
<asp:BoundField DataField="Branch" HeaderText="Branch"
SortExpression="Branch" />
<asp:BoundField DataField="Department_Name"
HeaderText="Department"
SortExpression="Department_Name" />
<asp:BoundField DataField="DoctorName" HeaderText="Doctor
Name"
SortExpression="DoctorName" />
<asp:BoundField DataField="AvailabilityStatus"
HeaderText="Generel Availability"
SortExpression="AvailabilityStatus" />
</Columns>
<RowStyle CssClass="gridheadsub02" />
<HeaderStyle CssClass="gridheadUsingcss " />
<AlternatingRowStyle CssClass="gridheadsub01" />
</asp:GridView>
</div>

Step 4:

Run the project,

You might also like