private void databind() { string key = Utils.ReplaceString(txtkey.Text.Trim()); string where = " RealName like '%" + key + "%' and State in (1,2,3)"; if (ddl_PayState.SelectedValue != "") { where += " and State=" + ddl_PayState.SelectedValue; } if (ddl_PreType.SelectedValue != "") { where += " and PreType=" + ddl_PreType.SelectedValue; } AspNetPager1.RecordCount = bll.GetRecordCount(where); Repeater1.DataSource = bll.GetListByPage(where, "ID desc", AspNetPager1.StartRecordIndex, AspNetPager1.EndRecordIndex); Repeater1.DataBind(); }
/// <summary> /// /// </summary> /// <param name="isFromRequest">是否是从url请求获取的参数值,默认为不是</param> private void databind(bool isFromRequest = false) { string where = " 1=1 "; string stateStr = HttpContext.Current.Request["state"] ?? ""; if (!string.IsNullOrWhiteSpace(stateStr)) { stateStr = Regex.Replace(stateStr, @"\s+", ""); string[] stateArr = stateStr.Split('_'); List <int> stateIntList = new List <int>(); try { for (int i = 0; i < stateArr.Length; i++) { stateIntList.Add(Convert.ToInt32(stateArr[i])); } } catch (Exception) { } stateIntList = stateIntList.Distinct().ToList(); var paramArr = new List <string>(); if (stateIntList.Any()) { foreach (var item in stateIntList) { paramArr.Add(string.Format(" state={0} ", item)); } where += string.Format(" and ( {0} ) ", string.Join(" or ", paramArr.ToArray())); } } string key = Utils.ReplaceString(txtkey.Text.Trim()); if (!string.IsNullOrWhiteSpace(key)) { where += " and (RealName like '%" + key + "%') "; } AspNetPager1.RecordCount = bll.GetRecordCount(where); Repeater1.DataSource = bll.GetListByPage(where, " state", AspNetPager1.StartRecordIndex, AspNetPager1.EndRecordIndex); Repeater1.DataBind(); }