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();
                        }
                    }
                }
            }
  • 相关阅读:
    lua 逻辑运算 and, or, not
    redis和memcache列出所有key
    Linux protobuf
    CGI,FastCGI,PHP-CGI与PHP-FPM
    lua使用笔记2:Linux 中安装php的lua扩展
    lua使用笔记1:Linux 中安装lua
    Android APK反编译详解
    git 常用命令
    git push 403错误解决方法
    linux(centos)搭建SVN服务器
  • 原文地址:https://www.cnblogs.com/zhuiyi/p/2047646.html
Copyright © 2011-2022 走看看