【问题标题】:hiding a column in asp.net在 asp.net 中隐藏一列
【发布时间】:2013-06-30 17:46:00
【问题描述】:

我想在网格视图中隐藏一列。我使用以下代码;

dgvTekleme.Columns[1].Visible = false;

但这不起作用。 (可能因为在代码中使用了该列而不起作用) 有没有办法在代码隐藏中隐藏一列

【问题讨论】:

    标签: asp.net gridview


    【解决方案1】:

    您可以手动执行此操作..... 转到 asp:gridview 标记并在 gridview 标记中设置 autogeneratecolumn="false" 如果您不想显示某些列,请不要写该列.... 例如,如果您不想显示 prodId 列,只需擦除该行.... 并手动编写以显示数据,例如!!!!!!!!!!

    <asp:GridView ID="gridview1"  runat="server" AutoGenerateColumns="false">
    <Columns>
    <asp:BoundField HeaderText="ProdID" DataField="prodid" ReadOnly="true" />
    <asp:BoundField HeaderText="ProdName" DataField="ProdName" />
    <asp:BoundField HeaderText="Quantity" DataField="quantity" />
    <asp:BoundField HeaderText="SupplierID" DataField="SupplierId" />
    <asp:BoundField HeaderText="StockLvl" DataField="stocklevel" />
    <asp:BoundField HeaderText="MinStockLvl" DataField="minstocklevel" />
    <asp:BoundField HeaderText="CostPrice" DataField="costprice" />
    <asp:BoundField HeaderText="SalesPrice" DataField="saleprice" />
    <asp:BoundField HeaderText="Loc" DataField="location" />
    <asp:BoundField HeaderText="ProdCode" DataField="prodtypecode" />
    <asp:CommandField ShowEditButton="true"  ShowDeleteButton="true" />
    </Columns>
    </asp:GridView>
    

    或者您可以查看此链接: How to hide columns in an ASP.NET GridView with auto-generated columns?

    【讨论】:

    猜你喜欢
    • 2010-09-17
    • 1970-01-01
    • 2017-07-31
    • 2017-07-06
    • 1970-01-01
    • 1970-01-01
    • 2011-07-17
    • 2020-06-16
    • 1970-01-01
    相关资源
    最近更新 更多