我正在尝试冻结gridview中的列,其中网格具有静态高度并且所有行都被渲染(没有分页和滚动变量可见)。 我只是设法通过溢出属性添加内容滚动,但这次所有列都滚动。我的任务是 冻结列,同时保持列宽 < /强>
让这成为我的网格
<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>
这是代码视图
public class Person
{
public String Name { get; set; }
public String Surname { get; set; }
}
- &gt;在页面加载
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();
如何通过最少的编码或样式工作来实现这一目标? 注意:渲染的浏览器仅限IE。