On Grid_RowDataBound
我在當前行的第8個單元格中添加了一個表格。此表是這樣的:在gridview中訪問動態控件中的數據
<table rules="all" border="0" style="width:100%;">
<tbody>
<tr>
<td align="center"><input name="studentgrd$ctl03$ID2VAL4" type="text" value="6" maxlength="2" id="studentgrd_ctl03_ID2VAL4" style="width:20px;"></td>
</tr>
</tbody>
</table>
在保存按鈕的點擊,我試圖讓數據使用:
TextBox tb = (TextBox)studentgrd.FindControl("ID2VAL4");
TextBox tb = (TextBox)studentgrd.Rows[i].Cells[8].FindControl("ID2VAL4");//When looping through all rows
但文本框爲空。那麼在回發中動態控件會丟失嗎?如果是,那麼如何保留它?如果不是,我會在哪裏出錯?
是回發時丟失的動態控制值。要獲得值添加隱藏字段,然後將文本框的值在隱藏字段中使用JavaScript在文本框的lostfocus事件。 – Raghubar
在那個單元格中會有動態數字的文本框如何決定隱藏字段的數量。 –