zoukankan      html  css  js  c++  java
  • GridView列中Visible="False"的异同

    <asp:TemplateField Visible="False">
    <ItemTemplate>
    <asp:Label ID="LblGoodsID" runat="server" Text='<%# bind("cGoodsID") %>'></asp:Label>
    </ItemTemplate>
     </asp:TemplateField>
    <asp:BoundField DataField="cGoodsID" Visible="False" />


        protected void OnUpdate(object sender, EventArgs e)
        {
            GridViewRow t = (GridViewRow)(((ImageButton)sender).Parent.Parent);
            Label LblGoodsID = (Label)t.FindControl("LblGoodsID");
            Response.Write(LblGoodsID.Text);
            Response.Write(t.Cells[1].Text);
        }

    同是Visible="False"第一个可以打印出来.第二个则没有被打印出来
     

    如果要在GridView 控件中隐藏不必要的列,使用visible="false"后 你就无法取得这列的值了.

    解决问题的方法很简单:

    --------------------------------------------------
     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                //隐藏不必要的列
                if ((e.Row.RowType == DataControlRowType.DataRow) || (e.Row.RowType == DataControlRowType.Header) || (e.Row.RowType == DataControlRowType.Footer))
                {
                    e.Row.Cells[0].Visible=false;
                    e.Row.Cells[3].Visible=false;
               
                }

    }

  • 相关阅读:
    canvas 文本坐标(0,0)显示问题
    canvas 图片跨域处理
    canvas 文字换行
    什么是柯理化函数?
    记录一下学习webpack原理的过程
    pika和kombu实现rpc代码
    pika和rabbitMQ实现rpc代码
    docker部署rabbitMQ
    rabbitMQ和pika模块
    ubuntu搭建关于amd64或arm64,armhf架构的本地apt源
  • 原文地址:https://www.cnblogs.com/chinafine/p/1255844.html
Copyright © 2011-2022 走看看