這是在C#中,但該事件是一樣的,你將目標。當用戶選擇一行時,該事件將被觸發,並將檢索所選行。一旦你有選定的行,你可以通過使用列的索引來獲得該行的任何列值。
void GridView1_SelectedIndexChanged(Object sender, EventArgs e)
{
// Get the currently selected row using the SelectedRow property.
GridView1 row = GridView1.SelectedRow;
// You could access any cell in the row by doing row.cells(index)
MessageLabel.Text = "You selected " + row.Cells[2].Text + ".";
}
希望有幫助!
編輯
VB
Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
' Get the currently selected row using the SelectedRow property.
Dim row As GridViewRow = GridView1.SelectedRow
MessageLabel.Text = "You selected " & row.Cells(2).Text & "."
End Sub
請參閱如果我的回答對你起作用,如果是,那麼請把它標記爲一個正確的答案 –