如何在asp.net中的网格视图中隐藏列 [英] how to hide column in grid view in asp.net

查看:75
本文介绍了如何在asp.net中的网格视图中隐藏列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview,它是数据库中的字段.所以如何隐藏gridview中的列

i have a gridview which is field from database.so how can hide column in gridview

推荐答案



本文可以为您提供帮助:
在ASP.NET中显示/隐藏GridView列 [ ^ ]
Hi,

This article can help you:
Show / Hide GridView Columns in ASP.NET[^]



将该特定列的visible属性设置为false.

set the visible property of that particular column to be false.


如果您正在使用
1.然后自动生成列
If you are working with
1. AutoGenerate Columns then
GrdCustomer.RowDataBound += new System.Web.UI.WebControls.GridViewRowEventHandler(GrdCustomer_RowDataBound);
.
.
.
void GrdCustomer_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
   e.Row.Cells[0].Visible = false;
}


2.然后,绑定域


2. Bound Fields then

<asp:BoundField DataField="CustomerName" Visible="false" />


3.模板字段


3.Template Field

<asp:TemplateField HeaderText="Customer Name" Visible="false">
    <ItemTemplate>
        <asp:Label Text='<%# Eval("CustomerName") %>' runat="server" ID="LblCusomerName" />
    </ItemTemplate>
</asp:TemplateField>


这篇关于如何在asp.net中的网格视图中隐藏列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆