我已经在我的网格视图中添加了一个新的文本框,并对其进行了绑定,但我想从新的文本框中获取数据,因为它没有被绑定。
For i As Integer = 0 To GridView1.Rows.Count - 1
column_value = GridView1.Rows(i).Cells(10).Text
next
如果使用 aTemplateField
Cells.Text
为空。您必须使用FindControl
来获取对控件的引用:
Dim column_values As New List(Of String)
For Each row As GridViewRow In GridView1.Rows
Dim txt As TextBox = DirectCast(row.FindControl("TextBoxID"), TextBox)
column_values.Add(txt.Text)
Next
替换TextBoxID
为您的正确 ID TextBox
。
请注意,我使用了 aList(Of String)
因为 aGridView
通常包含多行。