超链接gridview到另一个gridview

时间:2015-04-08 06:36:48

标签: vb.net

任何简单的例子: 当我点击表1中的链接时,它将显示在表2中(两个表都在同一页面上。表2是隐藏的)?两个表都有不同的数据,但都基于Staff_ID链接。

在互联网上找不到任何相关示例。

更新:我知道如何从表格链接到下一页。例如:

Protected Sub gvTable1_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles gvTable1.RowCommand

    Dim index As Integer = Convert.ToInt32(e.CommandArgument)
    Dim row As GridViewRow = gvTable1.Rows(index)

    Select Case e.CommandName
        Case "Select"
            Response.Redirect("profile?id=01&staffID=" & row.Cells(1).Text)
        Case Else
            'Do nothing
    End Select
End Sub

现在,只想知道如何在同一页面上将表格链接到表格。


好的,我明白了:

Protected Sub gvTable1_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles gvTabel1.RowCommand
    Dim index As Integer = Convert.ToInt32(e.CommandArgument)
    Dim row As GridViewRow = gvTable1.Rows(index)
    Select Case e.CommandName
        Case "Select"
            txtTableID.Text = gvTable1.DataKeys(index).Value.ToString
            LoadGridTable2()
        Case Else
            'Do nothing
    End Select
End Sub

1 个答案:

答案 0 :(得分:0)

如果你只是隐藏table2(我假设是一个DataGridView),你可以使用:

DataGridView1.Visible = False
DataGridView2.Visible = True

并通过DataGridView1点击事件

进行调用