VB编程问题,如何让结果显示在新窗(页面)口上?
思路:我设计了一个档案查询网页,查询功能已经做好.结果可以显示在页面的表格中现在请高手指点一下,我想点击一下"查询"按钮让结果显示在一个弹出窗口(或页面)中.希望能帮我修改代码~~~`
代码如下:
<head runat="server">
<title>档案查询</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="档案号:" width="75"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Width="100px"></asp:TextBox>
<asp:Label ID="Label2" runat="server" Text="档案名称:" width="80"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Width="100px"></asp:TextBox>
<p>
<asp:Label ID="Label3" runat="server" Text="档案类型:" width="76px"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" width="106px"> </asp:DropDownList></p>
<p>★<asp:Button ID="Button1" runat="server" Text="查询" />★</p> </div>
<asp:Label ID="Label4" runat="server" ForeColor="Blue" Text="[结果显示]:" Width="90px"></asp:Label>
<asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" GridLines="None" AutoGenerateDeleteButton="True" AutoGenerateEditButton="True" AutoGenerateSelectButton="True">
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
</asp:GridView>
</form>
</body>
</html>
后台代码:
Imports System.data
Imports System.IO
Partial Class _Default
Inherits System.Web.UI.Page
Dim conn As New SqlClient.SqlConnection
Dim ad1 As SqlClient.SqlDataAdapter
Dim ds1 As DataSet
Dim ssql As String
Dim a As String
Dim cmd As New SqlClient.SqlCommand
Dim s As Integer
Dim cha As Integer
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
End Sub
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
conn.ConnectionString = "server=localhost;database=档案查询;uid=sa;pwd=sa"
DropDownList1.Items.Add("")
DropDownList1.Items.Add("地形图")
DropDownList1.Items.Add("土地利用图")
DropDownList1.Items.Add("影象图")
DropDownList1.Items.Add("基本农田图")
End Sub
Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Protected Sub TextBox2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
conn.Open() '连接数据库
ssql = "select * from 档案查询 where " '变量
If TextBox1.Text = "" Then
Else
ssql = ssql + " and 档案号 like'%" & TextBox1.Text & "%' "
End If
If TextBox2.Text = "" Then
Else
ssql = ssql + " and 名称 like'%" & TextBox2.Text & "%' "
End If
ssql = ssql + " and 类型 like'%" & DropDownList1.Text & "%' "
Dim i As Integer '定义变量
For i = 1 To 5
ssql = Replace(ssql, " ", " ")
Next
ssql = Replace(ssql, "where and", "where ")
ssql = Replace(ssql, "where order", " order")
ad1 = New SqlClient.SqlDataAdapter(ssql, conn)
ds1 = New DataSet
ad1.Fill(ds1)
GridView1.DataSource = ds1.Tables.Item(0)
GridView1.DataBind()
conn.Close()
End Sub
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
conn.Open() '连接数据库
ssql = "select * from 档案查询 where "
End Sub
End Class --------------------编程问答-------------------- Deflautpage2.GridView1.DataSource = ds1.Tables.Item(0)
Deflautpage2.GridView1.DataBind()
conn.Close()
--------------------编程问答-------------------- 放在哪段代码中?
补充:.NET技术 , VB.NET