想获取GridView控件内的子控件可以利用GridView自身的事件来处理。
比如说:

利用RowDataBound事件:
    protected void RowDataBoumd(object sender, GridViewRowEventArgs e)
    {
           TextBox t 
= e.Row.FindControl("TextBox"as TextBox;
           Response.Write(t.Text);
    }

更多方式请点击这里

如果想要通过GridView控件外的某个控件,比如说<asp:Button ... />,则可以通过循环GridView控件的GridViewRow来获得,当然你是可以指定获取某行的,假如你能提供行号。
那这个Button的事件应该包含类似下面的代码:
        foreach (GridViewRow row in GridView1.Rows)
        {

            
this.Lable1.Text += "<br />" + (row.FindControl("txt_input"as TextBox).Text;

        }

哈,希望我的标题不会是哗众取宠。


相关文章: