日期:2014-05-16 浏览次数:20419 次
select 你那几个列我就不写了
from Student where (StudentID=''or StudentID=@StudentID)
and ([Name]='' or [Name]=@[Name])
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bind("");
}
}
protected void bind(string condition)
{
string sql = "select * from table where 1=1 " + condition;
}
protected void Button1_Click(object sender, ImageClickEventArgs e)
{
string condition = "";
if (!string.IsNullOrEmpty(Textid.Text))
{
condition += " and studentid =" + Textid.Text + "%'";//用+=
}
if (!string.IsNullOrEmpty(TextName.Text))
{
condition += " and name like '%" + TextName.Text + "%'";
}
//下面条件省略
}