zoukankan      html  css  js  c++  java
  • 如何获取gridview中模板列中控件的值?

           foreach (GridViewRow gvr in gvInBillList.Rows)
           {
              TextBox t 
    = gvr.FindControl("TextBox1"as TextBox;
              
    if (t != null)
              {
                  t.Text 
    = "给TextBox1赋值";
              }
           }

    这个方法真的很实用;把代码放到Page_Load中;

    其实在GridView的模板中操作真挺头疼的;也许是我真的好菜好菜; 

    其实其他控件还好,最疼头的应该是DropDownList吧,这个方法同样受用;

    protected void Page_Load(object sender, EventArgs e)
            {
                
    if (!IsPostBack)
                {
                    gvBind();

                    
    foreach (GridViewRow gvr in gvInBillList.Rows)
                    {
                        DropDownList ddlInType 
    = gvr.FindControl("ddlInType"as DropDownList;
                        
    if (ddlInType != null)
                        {
                            ddlInType.DataSource 
    = new InBillManager().GetAllInType();
                            ddlInType.DataTextField 
    = "Name";
                            ddlInType.DataValueField 
    = "Id";
                            ddlInType.DataBind();
                        }
                    }
                }
            }
  • 相关阅读:
    CSS3圆圈动画放大缩小循环动画效果
    php将多个值的数组去除重复元素
    .net 图片压缩
    关于FFmpegInterop项目的编译
    Axure Beta 7.0 汉化版下载
    axure 6.5 汉化正式版软件及注册码
    HTML基础复习(八)表单
    HTML基础复习(七)布局-div间距
    Android+GPS轨迹跟踪器(一)
    HTML基础复习(六)布局-居中
  • 原文地址:https://www.cnblogs.com/zhuiyi/p/2047646.html
Copyright © 2011-2022 走看看