'ColumnIndex'不是'System.EventArgs'的成员

时间:2014-01-06 12:46:31

标签: asp.net vb.net gridview

我在网站(.aspx页面)上使用vb.net

我遇到的错误是:'ColumnIndex'不是'System.EventArgs'的成员。

我使用的代码是:

Private Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged

        Dim CurrentCellName As String = GridView1.Columns(e.ColumnIndex).Name
        Dim CurrentCellValue As String = GridView1.SelectedCells(0).Value.ToString()
        Dim CurrentRow As DataGridViewRow = GridView1.Rows(e.RowIndex)

        Label23.text = "CCN: " & CurrentCellName & " CCV: " & CurrentCellValue & " CR: " & CurrentRow

        Session("PropertyID") = sender.SelectedValue.ToString
        PanelPropertyDetails.visible = "True"

    End Sub

1 个答案:

答案 0 :(得分:2)

如果要单击单元格上的当前列名称,可以使用:

Dim CurrentCellName as String = GridView1.Columns(e.ColumnIndex).Name

如果要获取Cell的值,可以使用

Dim CurrentCellValue as String = GridView1.SelectedCells(0).Value.ToString()

如果你想获得整行,你可以选择使用

Dim CurrentRow as DataGridViewRow = GridView1.Rows(e.RowIndex)

要将它放在您选择的事件处理程序中,它可能看起来像这样:

Private Sub GridView1_CellClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles GridView1.CellClick

 Dim CurrentCellName as String = GridView1.Columns(e.ColumnIndex).Name
 Dim CurrentCellValue as String = GridView1.SelectedCells(0).Value.ToString()
 Dim CurrentRow as DataGridViewRow = GridView1.Rows(e.RowIndex)

End Sub