搜索问题
下面是搜索代码,当我不输入搜索内容时不显示任何内容,我代码的意愿是不输入时显示所有记录protected void Button1_Click(object sender, EventArgs e)
{
string search = "";
if (this.Suserid.Text != "")
{
search = "userid=" + Convert.ToInt32(this.Suserid.Text) + "";
if (Susername.Text != null)
{
search += "and username ='" + Susername.Text + "'";
}
else
{
search += "and username like '%'";
}
}
else
{
search = "userid <>null ";
if (Susername.Text != null)
{
search += "and username ='" + Susername.Text + "'";
}
else
{
search += "and username like '%'";
}
}
DataView dv = new DataView(opends("user").Tables["user"]);
dv.RowFilter = search;
DataGrid1.DataSource = dv;
DataGrid1.DataBind();
}