现在的位置: 首页 > 综合 > 正文

URL参数搜索

2011年12月28日 ⁄ 综合 ⁄ 共 1494字 ⁄ 字号 评论关闭

1,构造URL搜索参数
   string strSearch = string.Empty;
   if (this.dropDistrict.SelectedIndex != 0)
   {
    strSearch += String.Format("{0} = '{1}'",( user.userID.Substring(0,6) == "230000") ? "City" : "District",dropDistrict.SelectedValue);
   }
   if (DropFQualiClassID.SelectedValue != "0")
   {
    strSearch += String.Format(" AND FQualiClassID = '{0}'",DropFQualiClassID.SelectedValue);
   }
   if (this.dropFQualiNclassID.SelectedValue != "0")
   {
    strSearch += String.Format(" AND FQualiNclassID = '{0}'",dropFQualiNclassID.SelectedValue);
   }
   if (dropFQualification.SelectedValue != "0")
   {
    strSearch += String.Format(" AND FQualification = '{0}'",dropFQualification.SelectedValue);
   }
   if (txtEnterName.Text.Trim() != "")
   {
    strSearch += String.Format(" AND FName LIKE '%{0}%'",txtEnterName.Text.Trim());
   }
   if (this.dropFYear.Visible)
   {
    strSearch += String.Format(" AND FYear = '{0}'",dropFYear.SelectedValue.Trim());
   }
   if (this.dropFQuarter.Visible)
   {
    strSearch += String.Format(" AND FQuarter = '{0}'",dropFQuarter.SelectedValue.Trim());
   }
   if (strSearch.Length > 5 && strSearch.Substring(0,5)==" AND ")
   {
    strSearch = strSearch.Remove(0,5);
   }

   if (strSearch.Length > 0)
   {
    Response.Redirect(String.Format("Enterprise/ApproveList.aspx?strSearch={0}",strSearch));
   }
   else
   {
    Response.Redirect("Enterprise/ApproveList.aspx");
   }
2,ApproveList.aspx 接收搜索参数 执行搜索
   if (Request.QueryString["strSearch"] != null)
   {
    DataTable dtTemp = dt.Copy();
    dt.Rows.Clear();
    dt = FilterBind(dtTemp,Request.QueryString["strSearch"].Trim());
   }

抱歉!评论已关闭.