我试图通过在 sql 命令中传递不同的查询来在三个按钮单击事件上显示相同的网格。
<table style="width:100%;" cellspacing="2" class="Text">
<tr>
<td align="left" colspan ="2">
<asp:Button ID="btnreport1" runat="server"
Text="Report1" Width="104px"
OnClick ="btnreport1_Click1"/>
</td>
</tr>
</table>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="True" AllowPaging="True"
AllowSorting="True">
</asp:GridView>
VB代码
Protected Sub btnreport1_Click1(sender As Object,
e As EventArgs) Handles btnreport1.Click
Using conn1 As New SqlConnection(ConfigurationManager.ConnectionStrings(
"TERAMSConnectionString").ConnectionString)
conn1.Open()
Dim cmd2 As SqlCommand =
New SqlCommand("select * from AssetsHardware_Master ,
Desktop where Serial_no !=SerialNo", conn1)
Dim dr As SqlDataReader = cmd2.ExecuteReader
Dim dt As DataTable = New DataTable
dt.Load(dr)
GridView1.DataSource = dt
GridView1.DataBind()
End Using
End Sub