<TABLE id="Table1" style="Z-INDEX: 101; LEFT: 248px; WIDTH: 624px; POSITION: absolute; TOP: 104px; HEIGHT: 272px"
cellSpacing="1" cellPadding="1" width="300" border="1">
<TR>
<TD style="HEIGHT: 51px" align="center" colSpan="2">员工信息模糊查询</TD>
</TR>
<TR>
<TD style="WIDTH: 222px; HEIGHT: 46px">请选择查询类型:</TD>
<TD style="HEIGHT: 46px"><asp:dropdownlist id="search_type" Runat="server">
<asp:ListItem Value="姓名" Selected="True"></asp:ListItem>
<asp:ListItem Value="性别"></asp:ListItem>
<asp:ListItem Value="籍贯"></asp:ListItem>
<asp:ListItem Value="民族"></asp:ListItem>
<asp:ListItem Value="学历"></asp:ListItem>
<asp:ListItem Value="部门"></asp:ListItem>
</asp:dropdownlist></TD>
</TR>
<TR>
<TD style="WIDTH: 222px; HEIGHT: 44px">请输入查询内容:</TD>
<TD style="HEIGHT: 44px"><asp:textbox id="txtcontent" Runat="server"></asp:textbox><asp:button id="button1" Runat="server" Text="确定"></asp:button></TD>
</TR>
<tr>
<td style="HEIGHT: 41px" align="center" colSpan="2"><FONT face="宋体">查询结果显示</FONT></td>
</tr>
<tr>
<td colSpan="2"><asp:datagrid id="grid_show" Runat="server" AutoGenerateColumns="False" GridLines="None" Width="616px"
AllowSorting="True" AllowPaging="True" CellPadding="2">
<SelectedItemStyle ForeColor="GhostWhite" BackColor="DarkSlateBlue"></SelectedItemStyle>
<AlternatingItemStyle BackColor="PaleGoldenrod"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" BackColor="Tan"></HeaderStyle>
<FooterStyle BackColor="Tan"></FooterStyle>
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="users_id" DataNavigateUrlFormatString="person_detail.aspx?users_id={0}"
DataTextField="users_id" HeaderText="员工编号">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField="username" SortExpression="username" HeaderText="姓名">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="sex" SortExpression="sex" HeaderText="性别">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="hometown" SortExpression="hometown" HeaderText="籍贯">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="nation" SortExpression="nation" HeaderText="民族">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="dep_name" SortExpression="dep_name" HeaderText="部门">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="users_id" HeaderText="users_id"></asp:BoundColumn>
</Columns>
</asp:datagrid></td>
</tr>
</TABLE>
这是.aspx,
cellSpacing="1" cellPadding="1" width="300" border="1">
<TR>
<TD style="HEIGHT: 51px" align="center" colSpan="2">员工信息模糊查询</TD>
</TR>
<TR>
<TD style="WIDTH: 222px; HEIGHT: 46px">请选择查询类型:</TD>
<TD style="HEIGHT: 46px"><asp:dropdownlist id="search_type" Runat="server">
<asp:ListItem Value="姓名" Selected="True"></asp:ListItem>
<asp:ListItem Value="性别"></asp:ListItem>
<asp:ListItem Value="籍贯"></asp:ListItem>
<asp:ListItem Value="民族"></asp:ListItem>
<asp:ListItem Value="学历"></asp:ListItem>
<asp:ListItem Value="部门"></asp:ListItem>
</asp:dropdownlist></TD>
</TR>
<TR>
<TD style="WIDTH: 222px; HEIGHT: 44px">请输入查询内容:</TD>
<TD style="HEIGHT: 44px"><asp:textbox id="txtcontent" Runat="server"></asp:textbox><asp:button id="button1" Runat="server" Text="确定"></asp:button></TD>
</TR>
<tr>
<td style="HEIGHT: 41px" align="center" colSpan="2"><FONT face="宋体">查询结果显示</FONT></td>
</tr>
<tr>
<td colSpan="2"><asp:datagrid id="grid_show" Runat="server" AutoGenerateColumns="False" GridLines="None" Width="616px"
AllowSorting="True" AllowPaging="True" CellPadding="2">
<SelectedItemStyle ForeColor="GhostWhite" BackColor="DarkSlateBlue"></SelectedItemStyle>
<AlternatingItemStyle BackColor="PaleGoldenrod"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" BackColor="Tan"></HeaderStyle>
<FooterStyle BackColor="Tan"></FooterStyle>
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="users_id" DataNavigateUrlFormatString="person_detail.aspx?users_id={0}"
DataTextField="users_id" HeaderText="员工编号">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField="username" SortExpression="username" HeaderText="姓名">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="sex" SortExpression="sex" HeaderText="性别">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="hometown" SortExpression="hometown" HeaderText="籍贯">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="nation" SortExpression="nation" HeaderText="民族">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="dep_name" SortExpression="dep_name" HeaderText="部门">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="users_id" HeaderText="users_id"></asp:BoundColumn>
</Columns>
</asp:datagrid></td>
</tr>
</TABLE>
这是.aspx,
解决方案 »
- asp.net2005中,如何将rdlc报表导出成pdf格式?
- 关于网站内容提取关键字的问题
- 高分求弹出窗口 返回选定TreeView值的代码(急)
- 求教关于asp.net2.0中treeview控件在模式窗口下的问题!
- 如何把我常用的代码做成一个dll可以在其它项目中使用?
- 怎样使RequiredFieldValidator只在点击某个特定的button后才开始验证,而不是实时验证,也就是说不是当输入完一个文本框就对该文本框径行验
- 求加密解密算法
- 怎样用OA的源程序??
- 老得不能再老的问题(DataGrid的嵌套)
- 在DataGrid的EditItemTemplate中加入Dropdownlist,编辑时如何设置DropDownList的默认值?
- ???如何实现这样的简单功能???
- 在datatable中,字段类型为single,怎么给其赋空值?
这个sql语句怎么编写,才能绑定到datagrid呢?
那么组合框的每一个value要和数据库的字段名一一对应string sql="select * from table where " + this.dropdown.Value + "" like '%'"+ this.TextBox1.Text + "'%'
protected void selectChange()
{
respose.redircet("SearchResult.aspx?cid="+ddl.selectedItem.Value+"&string="+;lable.Text);
}
dropdownlist 定义好value和text 对应 如:value=1 text="名称"
然后在searchresult.aspx页面接收条件
sql语句这样写:
string cid=request.querystring["cid"];
string str=request.querystring["string"];
string Query="select * from 表 where 1=1";
if (cid=="1")
{Query+=" and 名称字段 like '%"+str+"%'"}
if (cid=="2")
{Query+=" and 内容字段 like '%"+str+"%'"}
依此类推
这样明白不?
<asp:dropdownlist id="search_type" Runat="server">
<asp:ListItem Value="姓名" Selected="True"></asp:ListItem>
<asp:ListItem Value="性别"></asp:ListItem>
<asp:ListItem Value="籍贯"></asp:ListItem>选择查询类型:<asp:textbox id="txtcontent" Runat="server"></asp:textbox><asp:button id="button1" Runat="server" Text="确定"></asp:button><asp:datagrid id="grid_show" Runat="server" AutoGenerateColumns="False" GridLines="None" Width="616px">
<asp:ListItem Value="数据库里姓名的字段名" Selected="True">姓名</asp:ListItem>
<asp:ListItem Value="数据库里性别的字段名">性别</asp:ListItem>
<asp:ListItem Value="数据库里籍贯的字段名">籍贯</asp:ListItem>
</asp:dropdownlist>
选择查询类型:<asp:textbox id="txtcontent" Runat="server"></asp:textbox><asp:button id="button1" Runat="server" Text="确定" OnClick="button1_Click"></asp:button>
</div> protected void button1_Click(object sender, EventArgs e)
{
string sql = "select * from table where " + this.search_type.SelectedValue + " like '%" + this.txtcontent.Text + "%'"; Response.Write(sql);
}
{
string sql = "select * from table where " + this.search_type.SelectedValue + " like '%" + this.txtcontent.Text + "%'";
BindGrid(); //绑定datagrid就可以了吗?
}
for(int i =0 ;i<dropdownlist.Items.Count;i++)
{
s += dropdownlist.Item[i].ToString();}
string sql = "select * from table where username like '%"+s+"%'";
public DataSet SearchProduct(int start,string key, string way, string price, string category,int sorts)
{
Ds = new DataSet();
string Query = "select * from product where 1=1";
if (way != "")
{
switch (way)
{
case "1":
Query += " and name like '%" + key + "%'";
break;
case "2":
Query += " and introduce like '%" + key + "%'";
break;
case "3":
Query += "and detail like '%" + key + "%'";
break;
case "4":
Query += "and like '%" + key + "%'";
break;
}
}
if (price != "")
{
double p = Convert.ToDouble(price);
switch (price)
{
case "1":
break;
case "2":
Query += " and price2<10" ;
break;
case "3":
Query += " and price2<20" ;
break;
case "4":
Query += " and price2<50";
break;
case "5":
Query += " and price2<100";
break;
case "6":
Query += " and price2<500";
break;
case "7":
Query += " and price2>=500";
break;
} }
if (category != "")
{
if (category != "all")
{
int c = Convert.ToInt32(category);
Query += " and categoryid="+c;
}
}
if (sorts != 0)
Query += " and sortsid=" + sorts;
SqlDa = new SqlDataAdapter(Query,SqlConn);
SqlDa.Fill(Ds,start,20,"product");
SqlConn.Close();
return Ds;
}
我能再问你个问题吗?