asp.net关于显示数据和搜索的问题

来源:百度知道 编辑:UC知道 时间:2024/05/16 00:05:19
我想要做一个实现显示和搜索在同一个页面进行的页面,应该要怎么做呢?开始时候把数据库中的内容绑定到dataview中,然后在搜索以后,上面的内容实现更换,应该怎么去做呢?页面代码如下(数字有限制,非必要的没列不来):
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="0">编号</asp:ListItem>
<asp:ListItem Value="1">流水号</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="TextBox1" runat="server" Height="7px" Width="167px"></asp:TextBox>
<asp:Button ID="sou_botton" runat="server" Text="搜索" OnClick="sou_botton_Click" />
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" G

这个很好理解啊,
第一.在page_load里把数据全部显示出来
第二.在按钮的click事件里写出查询条件,并显示,你分2个点来想,没什么特别的

写一个BindData(string dropValue,string textValue){}的函数用来绑定Gridview,在page_load的时候调用它参数就传this.DropDownList1.SelectedValue和this.TextBox1.Text.Trim(),在sou_botton_Click事件里也这样调用就可以了