สอบถาม asp.net FindControl หน่อยคับเวลาจะอ้าง index ใน Gridview
Code (VB.NET)
For i As Integer = 0 To GridView1.Rows.Count - 1
Dim DS As TextBox
DS = GridView1.Rows(i).FindControl("txtID")
If DS.Text = "" Then
MsgBox("d")
Else
MsgBox("y")
End If
Next
Sub Button1_Click(sender As Object, e As EventArgs)
Dim chkCusID As CheckBox
Dim lblID As Label
Dim i As Integer
lblText.Text = ""
For i = 0 To myGridView.Rows.Count - 1
chkCusID = myGridView.Rows(i).FindControl("chkCustomerID")
lblID = myGridView.Rows(i).FindControl("lblCustomerID")
IF chkCusID.Checked = True Then
'*** Have lblID.Text ***'
Me.lblText.Text = Me.lblText.Text & "<br>" & lblID.Text
End IF
Next
End Sub
Protected Sub Button36_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button36.Click
For i As Integer = 0 To GridView1.Rows.Count - 1
Dim txtID As TextBox = CType(GridView1.Rows(i).FindControl("txtID"), TextBox)
MsgBox(txtID.Text)
Next
End Sub