[英]How to retrieve TextBox Value from GridView
I have a gridview
and created dynamic TextBox
in the RowDataBound
event as我有一个
gridview
并在RowDataBound
事件中创建了动态TextBox
作为
TextBox txtbox = new TextBox();
txtbox.ID = "txt1";
txtControl.Text = "SoomeValue";
When I'm trying to retrieve the value on a button click
as当我尝试检索
button click
上的值时, button click
为
TextBox textboxValue = (TextBox)gv.Rows[rowIndex].Cells[cellIndex].FindControl("txt1");
string value = textboxValue.Text;
It is always returning null
beside it is having the value
它总是返回
null
除了它具有value
Answer is No. You cannot retrieve dynamically added TextBox from GridView like you are trying.答案是否定的。您无法像尝试一样从 GridView 中检索动态添加的 TextBox。
If you use GridView, you need to add textbox inside Template Column at Design Time .如果您使用 GridView,则需要在设计时在模板列中添加文本框。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.