URL参数搜索

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());
   }

posted @   ejiyuan  阅读(448)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示