C# Gridview文本框在';findcontrol';

C# Gridview文本框在';findcontrol';,c#,asp.net,vb.net,C#,Asp.net,Vb.net,我有一个gridview,在代码隐藏中动态添加文本框模板字段,并在文本框中输入值。获取文本框值时,它返回空值 在下面的代码中,我试图获取值 '***在执行下面的代码之前,我在文本框控件中输入了“Hello”值 For Each row As GridViewRow In GridviewChild.Rows Dim tbSigningGroup As TextBox = DirectCast(row.Cells(4).FindControl("tbSigningGrou

我有一个gridview,在代码隐藏中动态添加文本框模板字段,并在文本框中输入值。获取文本框值时,它返回空值

在下面的代码中,我试图获取值

'***在执行下面的代码之前,我在文本框控件中输入了“Hello”值

For Each row As GridViewRow In GridviewChild.Rows

            Dim tbSigningGroup As TextBox = DirectCast(row.Cells(4).FindControl("tbSigningGroup" + CStr(row.RowIndex)), TextBox)

            If Not tbSigningGroupIs Nothing Then
                Dim temp As String = tbSigningGroup.Text  ' ****** Returns NULL*******
            End If

Next

您的问题不够清楚,无法解决您的问题。为了清晰起见,请发布您的ASPX标记和代码隐藏事件(例如
RowDataBound
)。如果您使用的是
ItemTemplate
,只需在GridView上找到文本框,例如
DirectCast(row.FindControl(“tbSigningGroup”)和CStr(row.RowIndex)),textbox)
。为什么不按
列和
单元格使用
textbox
索引呢?而不是使用控件的名称。