protected void GridView2_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.Cells.Count >= 4)
{
e.Row.Cells[0].Visible = false;//设置第1列为隐藏列
e.Row.Cells[1].Visible = false;//设置第2列为隐藏列
e.Row.Cells[2].Width = 150;
{
if (e.Row.Cells.Count >= 4)
{
e.Row.Cells[0].Visible = false;//设置第1列为隐藏列
e.Row.Cells[1].Visible = false;//设置第2列为隐藏列
e.Row.Cells[2].Width = 150;
e.Row.Cells[3].Width = 150;
}
}
本文介绍如何使用ASP.NET中的GridView控件自定义行创建事件,通过编程方式隐藏不需要显示的列,并调整可见列的宽度。
328

被折叠的 条评论
为什么被折叠?



