如何在自动生成的列中隐藏ASP.NET GridView中的列?
发布时间:2020-05-23 05:26:07 所属栏目:asp.Net 来源:互联网
导读:GridView1.Columns.Count总是为零,甚至SqlDataSource1.DataBind(); 但Grid是确定 我可以 for (int i = 0; i GridView1.HeaderRow.Cells.Count;i++) 我在这里重命名请求标头 但 GridView1.Columns[i].Visible = false; 我不能使用它,因为GridView1.Co
|
GridView1.Columns.Count总是为零,甚至SqlDataSource1.DataBind(); 但Grid是确定 我可以 for (int i = 0; i < GridView1.HeaderRow.Cells.Count;i++) 我在这里重命名请求标头 GridView1.Columns[i].Visible = false; 我不能使用它,因为GridView1.Columns.Count是0。 那么我该如何隐藏呢? 解决方法尝试把e.Row.Cells [0] .Visible = false;在您的网格的RowCreated事件内。protected void bla_RowCreated(object sender,GridViewRowEventArgs e)
{
e.Row.Cells[0].Visible = false; // hides the first column
}
这样就自动隐藏整个列。 您不能通过grid.Columns [i]在gridview的DataBound事件中访问生成的列。 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 在mvc4 asp.net中的Razor View中的模型声明
- asp.net-mvc – 尝试继承RegularExpressionAttribute,不再验
- asp.net – 如何解决错误:当应用程序未在UserInteractive模
- ASP.NET和会话 – 新的浏览器实例与新的浏览器窗口
- ASP.NET Core 2.0仅在共享文件夹中查找视图
- asp.net-mvc – FluentValidation客户端验证
- asp.net-mvc – Jasmine在一个单独的测试项目中
- 休息 – ASP.NET Web API授权和身份验证
- asp.net-mvc – 安装KB2993928后,ASP.NET MVC4解决方案无法
- ASP.Net MVC Cookies不会持续存在
推荐文章
站长推荐
- asp.net-mvc – Asp.Net MVC – 进修课程
- asp.net-mvc – 使用带有剃刀的html选择框
- asp.net – StyleBundle索引超出了数组的边界
- azure – 使用VSTS的ASP.NET Core Web API的CI/C
- asp.net-mvc-3 – 我应该尝试使用MVC3和ASP.net的
- asp.net-mvc – 是否可能在剃刀中嵌套一个窗体另
- asp.net – 评论.aspx
- ASP.NET MVC 3 Ajax.BeginForm和Html.TextBoxFor
- asp.net-mvc – 是否可以在MVC控制器中的一个操作
- asp.net-mvc – 可以在mvc JsonResult控制器方法
热点阅读
