开发者

Filtering dataset with condition

I am using asp.net 2.0 and c#.

I have a dataset, which is getting the employee info. Now I want to filter the gridview based on a name that the user has put in the search textbox.

I am doing this:

DataSet ds = new DataSet("EmployeeInformation");
//........ loading DataSet ds with emploee info
string strExpr;
strExpr = "Name LIKE %" + txtSearchEmployee.Text.Trim() + "%";
ds.Tables[0].Select(strExpr);

开发者_高级运维I am getting an error in the last step, that the operator is missing.

Please guide me how can I achieve this. Thanks in advance.


You just need to add single quotes around your LIKE criteria:

strExpr = "Name LIKE '%" + txtSearchEmployee.Text.Trim() + "%'";
ds.Tables[0].Select(strExpr);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜