多字段模糊查询
Tree_Organize.Nodes.Clear();
DataTable dt = organize.select_Orgcode();
DataRow[] rows = dt.Select(‘怎么加条件’);
foreach (DataRow dr in rows)
{
TreeNode node = new TreeNode();
node.Tag = dr;
node.Text = dr["Orgname"].ToString();
Tree_Organize.Nodes.Add(node);
}
这个怎么写啊 各位大侠
http://msdn.microsoft.com/zh-cn/library/system.data.datatable.select.aspx基本语法跟SQL语句类似
Condition.Append(" or Redtel like '%" + sing + "%' or Gongantel like '%" + sing + "%' or Safetel like '%" + sing + "%' or Dutytel like '%"+sing+"%'");
Condition.Append(" or Extension like '%" + sing + "%' or Fax like '%" + sing + "%' or Roomnum like '%" + sing + "%' or Zip like '%"+sing+"%'");
Condition.Append(" or Officeaddress like '%" + sing + "%' or Res like '%" + sing + "%' or Fullname like '%" + sing + "%' or Url like '%"+sing+"%'");
Condition.Append(" or Email like '%" + sing + "%' or Orgname like '%" + sing + "%' or Orgcode like '%"+sing+"%'");
Condition.Append(" or charindex(','+'" + Condition + "'+',',','+ltrim(Officetel)+',')>0 ");
跟写sql条件一样
System.Data.DataTable dataTable1 = new System.Data.DataTable("BlogUser");
System.Data.DataRow dr;
dataTable1.Columns.Add(new System.Data.DataColumn("UserId", typeof(System.Int32)));
dataTable1.Columns.Add(new System.Data.DataColumn("UserName", typeof(System.String)));
dataTable1.PrimaryKey = new System.Data.DataColumn[] { dataTable1.Columns["UserId"] }; for (int i = 0; i < 8; i++)
{
dr = dataTable1.NewRow();
dr[0] = i;
dr[1] = "【孟子E章】" + i.ToString() ;
dataTable1.Rows.Add(dr);
} System.Data.DataRow[] drs = dataTable1.Select("UserId >2 and ( UserName Like '%6%' or UserName Like '%5%')");
for (int i = 0; i < drs.Length; i++)
{
Response.Write("<li>" + drs[i][1]);
}