0

我已经在我的网格视图中添加了一个新的文本框,并对其进行了绑定,但我想从新的文本框中获取数据,因为它没有被绑定。

For i As Integer = 0 To GridView1.Rows.Count - 1
            column_value = GridView1.Rows(i).Cells(10).Text
next 
4

1 回答 1

0

如果使用 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通常包含多行。

于 2013-10-18T11:30:04.173 回答