请教高人一下:我下面这段用来“查询”的代码
为什么不是我想要结果!
难道是我的编程思想出了故障?
protected void btnselect_Click(object sender, EventArgs e)
{
string condition = "";//定义一个变量,用来查询的条件;
if (this.chkID.Checked)//通过数据表的ID来查询
{
if (this.chkID.Text == "")
{
condition = "pID like '%'";
}
else
{
condition =Convert.ToString("pID" ==this.txtID.Text);//把我想要查询ID添在“textbox”控件里且“checkbox”为真
}
}
else
{
condition = "pID like '%'";
}
if (this.chkname.Checked)
{
condition += " and personName like '%" + this.txtname.Text + "%'";
}
if (this.chksex.Checked)
{
if (this.rBtnNan.Checked)
{
condition += " and personSex='男'";
}
else
{
condition += " and personSex='女'";
}
}
DataView dv = new DataView(personoperat.selectAllPerson());
dv.RowFilter = condition;
dv.Sort = "pID Desc";
this.GridView1.DataSource = dv;
this.GridView1.DataBind();
}
}
谢谢!