加载的时候
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            gvTotalPlugCash.DataBind();
        }
    }
其实gridview啥都没有
 然后在databound里获取控件,手动绑定。
protected void gvTotalPlugCash_DataBound(object sender, EventArgs e)
    {
        
    }
请问咋获得控件,空间在第一行第三列

解决方案 »

  1.   


    TextBox tb = (TextBox)e.items[0].Cells[2].FindControl("TextBox1");
      

  2.   

    先是判断e.Row.RowType,如果类型是DataRow,那就e.Row.FindControl("控件ID")
      

  3.   

    愁databound事件
      e.row或者e.Items[]是出不来的
      

  4.   

     Label lbl1 = (Label)e.Row.Cells[0].FindControl("lbl1");
                if (lbl1 != null)
                {
                    string str = lbl1.Text;
                }
      

  5.   

     for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    Label lbl1 = (Label)GridView1.Rows[i].Cells[0].FindControl("lbl1");
                    if (lbl1 != null)
                    {
                        string str = lbl1.Text;
                    }
                }
      

  6.   

    你把第2个参数换成rowDatabound事件里的第2个试下
      

  7.   

    刚加载的时候gridview里什么数据都没有,
    所以gridview1.rows.count是0.
    控件也就获取不到