我想通過在sql命令中傳遞不同的查詢來在三個按鈕單擊事件上顯示相同的網格。Gridview在按鈕單擊上不可見
<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
當我嘗試相同的事情作爲一個單獨的應用程序其工作正常,我從最後三天卡在這裏。 – Miank