你的位置:首页 > ASP.net教程

[ASP.net教程]值得学习的代码2


 1 public string GetSWhere() 2     { 3       StringBuilder sb = new StringBuilder(); 4       sb.Append("select UserId,RealName,UserName,pwd,Phase,QQ from UserInfor where 1=1 "); 5       string username = txtSUserName.Text.Trim(); 6       if (!string.IsNullOrEmpty(username)) 7       { 8         sb.Append(string.Format(" and UserName='{0}'", username)); 9       }10       if (ddlSPhase.SelectedIndex > 0)11       {12         sb.Append(string.Format(" and Phase='{0}'", ddlSPhase.SelectedValue));13       }14       return sb.ToString();15     }