将Gridviews与sqldatasources结合使用

时间:2016-06-13 19:21:03

标签: asp.net vb.net gridview sqldatasource

下午好。我有三个包含sqldatasource的gridviews。两个网格都是5x2。我想弄清楚的是如何将多个网格视图组合到一个表中。为了获得该结果,每当我从下拉列表中选择一个项目(也有sqldatasource)时,它将显示组合的三个网格视图的表格。 我试图对它进行编码,但绝对没有结果。

 Imports System.Data
 Imports System.Data.SqlClient
 Imports System.Configuration

Partial Class companydropdown
Inherits System.Web.UI.Page

Protected Sub OnDataBound(sender As Object, e As EventArgs)

    Dim Gridview1 As New DataTable
    Dim GridView2 As New DataTable
    Dim GridView3 As New DataTable



    Dim primaryKey(0) As DataColumn
    Gridview1.PrimaryKey = {Gridview1.Columns("CompanyID")}
    GridView2.PrimaryKey = {GridView2.Columns("MemberTypeID")}
    GridView3.PrimaryKey = {GridView3.Columns("ReportNameID")}

    Gridview1.Merge(GridView2, False, MissingSchemaAction.AddWithKey)
    GridView2.Merge(GridView3, False, MissingSchemaAction.AddWithKey)

End Sub
End Class

0 个答案:

没有答案