本文介绍了如何冻结GridView中的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图冻结gridview中的网格grid有静态高度和所有行渲染(没有分页和滚动var是可见的)。我只能通过溢出属性添加滚动内容,但这一次所有列都滚动。我的任务是 冻结列,同时保持列宽
让这是我的网格
< div style =height:200px; overflow:auto;>
< asp:GridView ID =GridView1runat =serverAutoGenerateColumns =False
UseAccessibleHeader =true or false>
< Columns>
< asp:BoundField DataField =NameHeaderText =Name/>
< asp:BoundField DataField =SurnameHeaderText =Surname/>
< / Columns>
< / asp:GridView>
< / div>
这是代码视图
public class Person
{
public String Name {get;组; }
public String Surname {get;组; }
}
- >网页载入
列表< 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();
如何以最少的编码或样式实现这个目标?
注意:渲染的浏览器是仅IE。
解决方案
您可以使用Ideasparks 。
- 从。
I'm trying to freeze columns in gridview where grid has static height and all rows are rendered(no paging and scroll var is visible).I only managed to add scroll through content by overflow property,but this time all columns are scrolling as well.My task is to freeze columns while maintaining column width.
Let this be my grid
<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 code view
public class Person
{
public String Name { get; set; }
public String Surname { get; set; }
}
->On Page Load
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 minimum effort of coding or styling?
Note:Rendered browser is IE only.
解决方案
You could use the Ideasparks CoolGridView instead. It works fine for me and is free.
- Download from Codeplex.com.
这篇关于如何冻结GridView中的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!