I am trying to freeze columns in a gridview where grid has a static height and all rows are rendered (paging and scroll var are not visible). I managed to add content scrolling using the overflow property , but this time all the columns also scroll. My task is to freeze the columns while keeping the column width .
Let it be my net
<div style="height:200px;overflow:auto;">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
UseAccessibleHeader="true or false">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Surname" HeaderText="Surname" />
</Columns>
</asp:GridView>
</div>
and this is the kind of code
public class Person
{
public String Name { get; set; }
public String Surname { get; set; }
}
-> Page loading
List<Person> lst = new List<Person>();
lst.Add(new Person() { Name = "A", Surname = "A1" });
lst.Add(new Person() { Name = "B", Surname = "B1" });
lst.Add(new Person() { Name = "C", Surname = "C1" });
lst.Add(new Person() { Name = "D", Surname = "D1" });
lst.Add(new Person() { Name = "E", Surname = "E1" });
lst.Add(new Person() { Name = "F", Surname = "F1" });
lst.Add(new Person() { Name = "G", Surname = "G1" });
lst.Add(new Person() { Name = "H", Surname = "H1" });
lst.Add(new Person() { Name = "I", Surname = "I1" });
lst.Add(new Person() { Name = "J", Surname = "J1" });
lst.Add(new Person() { Name = "K", Surname = "K1" });
GridView1.DataSource = lst;
GridView1.DataBind();
How can I achieve this with minimal coding or style effort?
Note. The presented browser is only IE.
source
share