我看了一段代码,不知道为什么要用if (strLength > 4) strFilter = strTempFilter.Remove(strLength-5,4);
如题:为什么要用这个呢?到底删去了里面什么呢?
if (strLength > 4)
strFilter = strTempFilter.Remove(strLength-5,4);
-----------------------------------------------------------------------------------
1:
string strFilter = "";
string strTempFilter = "";
if (this.txt_mingcheng.Text.Trim() != "")
strTempFilter += "mingcheng like '" + this.txt_mingcheng.Text.Trim() + "%' and ";
if (this.txt_changshang.Text.Trim() != "")
strTempFilter += "changshang like '" + this.txt_changshang.Text.Trim() + "%' and ";
int strLength = strTempFilter.Length;
if (strLength > 4)
strFilter = strTempFilter.Remove(strLength-5,4);
ViewState["strFilter"] = strFilter;
BindDataGrid();
---------------------------------------------------------------------------------------
2:
string strFilter="";
string strTempFilter="";
if(this.txt_mingcheng.Text.Trim()!=null)
strTempFilter+=" mingcheng like '"+txt_mingcheng.Text.Trim()+"%'and";
if(this.txt_Danwei.Text.Trim()!=null)
strTempFilter+=" danwei like '"+txt_Danwei.Text.Trim()+"%'and";
if(this.list_blPay.SelectedIndex==0)
{}
else if(this.list_blPay.SelectedIndex==1)
strTempFilter+=" fukuanfou = ' 未知 ' and ";
else if(this.list_blPay.SelectedIndex==2)
strTempFilter+=" fukuanfou = '是'and";
else if(this.list_blPay.SelectedIndex==3)
strTempFilter+=" fukuanfou = ' 否 ' and ";
if(this.DropDownList2.SelectedIndex!=0)
strTempFilter+="riqi='"+DropDownList2.SelectedIndex.ToString().Trim()+"%'and";
int strLength=strTempFilter.Length;
if(strLength>4)
strFilter=strTempFilter.Remove(strLength-5,4);
ViewState["strFilter"]=strFilter;
BindDataGrid();