簡體   English   中英

如何從 GridView 檢索文本框值

[英]How to retrieve TextBox Value from GridView

我有一個gridview並在RowDataBound事件中創建了動態TextBox作為

TextBox txtbox = new TextBox();
txtbox.ID = "txt1";
txtControl.Text = "SoomeValue";

當我嘗試檢索button click上的值時, button click

    TextBox textboxValue = (TextBox)gv.Rows[rowIndex].Cells[cellIndex].FindControl("txt1");
    string value = textboxValue.Text;

它總是返回null除了它具有value

答案是否定的。您無法像嘗試一樣從 GridView 中檢索動態添加的 TextBox。

如果您使用 GridView,則需要在設計時在模板列中添加文本框。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM