我有一个ASP.NET DataGrid,最后返回三个可单击的列。运行SelectedIndexChanged时,如何返回单击的项的值?
由于
Private Sub DG_SelectedIndexChanged(sender As Object, e As EventArgs)
Try
Dim DG As GridView = CType(sender, GridView)
Dim vID As Integer = DG.SelectedRow.Cells(0).Text
'Need to determine which item was clicked here
Catch ex As Exception
End Try
End Sub
答案 0 :(得分:0)
最后我发现唯一的方法是将一个onclick事件添加到LinkButton
AG_Link.Text = "View Agenda"
AG_Link.Attributes.Add("onclick", "returnDocumentType('Agenda');")
添加一些JavaScript来更新隐藏的文本框,然后选择结果
Private Sub DG_SelectedIndexChanged(sender As Object, e As EventArgs)
Try
Dim DG As GridView = CType(sender, GridView)
Dim vID As Integer = DG.SelectedRow.Cells(0).Text
Dim DocumentType As String = DocumentTypeTB.Text
Catch ex As Exception
End Try
End Sub
有点长,但有效: - )