我有一个网格视图,我在运行时将文本框添加到每个单元格。但是,我似乎无法使用访问这些控件findcontrol
以下是我将文本框添加到网格视图的方法:
If e.Row.RowType = DataControlRowType.DataRow Then
For i = 1 To e.Row.Cells.Count - 1
Dim txtSchedule As New TextBox()
txtSchedule.ID = "txtSchedule" & i.ToString
e.Row.Cells(i).Controls.Add(txtSchedule)
Next
End If
当我去找控件时,它说它们什么都没有:
GridView1.Rows(0).Cells(cellindex).FindControl("txtSchedule" & cellindex.ToString)
EDIT问题是,在填充文本框后,它会重新创建文本框,因为我将它们放在创建的行中
在添加控件的行的单元格中使用 FindControl:
GridView1.Rows(0).Cells(cellindex).FindControl("txtSchedule" & cellindex.ToString)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)