【小技巧】在GridView控件外获取GridView内的控件
2007-07-07 17:19
323 查看
想获取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;
}
哈,希望我的标题不会是哗众取宠。
比如说:
利用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;
}
哈,希望我的标题不会是哗众取宠。
相关文章推荐
- 【小技巧】获取GridView内的控件
- 获取GridView内TextBox控件的值
- 获取GridView中某一行的控件
- 用JavaScript获取Gridview中某个触发事件控件的ID
- GridView,DataList控件获取当前行的行号
- 获取Asp.net GridView控件当中总的记录数量
- gridview 获取内部控件
- js循环获取gridview中的控件
- GridView控件中点击该行获取id值
- GridView控件RowDataBound事件中获取列字段的几种途径
- 不使用GridView自带编辑删除等等按钮,放置服务器控件的按钮。获取点击按钮的当前行以便进行编辑删除
- JavaScript 获取GridView模板列中用户控件的值?
- GridView 模板列 在后台获取该行某控件的值 例如批量修改
- VC小技巧一:获取窗口句柄、控件ID、DC等
- JavaScript获取GridView控件中选中行的行号和指定列的值
- robotium获取所有控件GridView、ScrollView下所有控件
- GridView,DataList控件获取当前行的行号
- 获取GridView控件中指定列的值
- Gridview模板列中控件的单击事件获取主键ID
- GridView控件RowDataBound事件中获取列字段值的几种途径