Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I have specific requirement as below.
I have a GridView generated in my code where 2 columns will have buttons and the remaining columns are auto-generated.
In this GridView, I have to freeze the header row and the two columns which has buttons.

Is it possible?
Because when I search I'm getting the header rows can't be frozen in a GridView where AutoGenerateColumn = "true".

Kindly suggest.

Please find the Grid structure below:


XML
<asp:GridView ID="grdInternalCostRateData" runat="server" CellPadding="3" EnableModelValidation="True"
                           ForeColor="Black" GridLines="Vertical" BackColor="White" BorderColor="#999999"
                           BorderStyle="Solid" BorderWidth="1px" OnRowEditing="grdInternalCostRateData_RowEditing"
                           OnRowCancelingEdit="grdInternalCostRateData_CancelEdit" OnRowDeleting="grdInternalCostRateData_RowDeleting"
                           OnRowUpdating="grdInternalCostRateData_RowUpdate" OnRowUpdated="grdInternalCostRateData_RowUpdated">
                           <AlternatingRowStyle BackColor="#CCCCCC" />
                           <Columns>
                               <asp:CommandField ShowEditButton="True" ButtonType="Button"  />
                               <asp:CommandField ShowDeleteButton="True" ButtonType="Button" />
                           </Columns>
                           <FooterStyle BackColor="#CCCCCC" />
                           <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
                           <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                           <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                       </asp:GridView>



Thanks & Regards,
Mathi.
Posted
Updated 26-Jan-15 20:56pm
v2

1 solution

 
Share this answer
 
Comments
Mathi2code 23-Jan-15 9:29am    
Hi Tejas,
Thanks for the response.
But the solution whichever you gave was if the number of columns are fixed isn't it?
what should I do if the the AutoGenerateColumn = "true" in the my grid.

Also I want to freeze the column 0 and column 1 when we scroll horizontally.

With Regards,
Mathi
Tejas Vaishnav 27-Jan-15 1:25am    
actually i have gave you sample, as per your requirement, you need to work on it and make appropriate changes to get your solution.
You can achive froze header and also column too, even if your AutoGeneratedColumn = true.

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