private void BindSmsTemplate() { htmlAppend += "<div id=\"myDataForSmsTemplate\" style=\"display:none;\">"; SmsTemplate bll = new SmsTemplate(); var list = bll.GetList(pageIndex, pageSize, out totalRecords, ""); if (list != null && list.Count > 0) { string itemAppend = ""; foreach (var model in list) { string templateType = ""; if (model.TemplateType == "auto") { templateType = "自动"; } else if (model.TemplateType == "custom") { templateType = "自定义"; } itemAppend += "{\"Id\":\"" + model.Id + "\",\"Title\":\"" + model.Title + "\",\"TemplateType\":\"" + templateType + "\",\"IsDefault\":\"" + model.IsDefault + "\",}"; } itemAppend = itemAppend.Trim(','); itemAppend = "{\"total\":" + totalRecords + ",\"rows\":[" + itemAppend + "]}"; htmlAppend += itemAppend; } htmlAppend += "</div>"; }
public string GetJsonBySmgTemplate(int pageIndex, int pageSize, string title) { string json = ""; if (pageIndex < 1) { pageIndex = 1; } if (pageSize < 1) { pageSize = 10; } int totalRecords = 0; string sqlWhere = ""; try { ParamsHelper parms = new ParamsHelper(); if (!string.IsNullOrWhiteSpace(title)) { sqlWhere += "and Title like @Title "; SqlParameter parm = new SqlParameter("@Title", SqlDbType.NVarChar, 50); parm.Value = "%" + title + "%"; parms.Add(parm); } SmsTemplate bll = new SmsTemplate(); var list = bll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms.ToArray()); if (list != null && list.Count > 0) { string itemAppend = ""; foreach (var model in list) { string isAutoText = ""; if (model.TemplateType == "auto") { isAutoText = "自动"; } else if (model.TemplateType == "custom") { isAutoText = "自定义"; } string isDefaultText = model.IsDefault ? "是" : "否"; itemAppend += "{\"Id\":\"" + model.Id + "\",\"Title\":\"" + model.Title + "\",\"IsAuto\":\"" + isAutoText + "\",\"IsDefault\":\"" + isDefaultText + "\"},"; } itemAppend = itemAppend.Trim(','); itemAppend = "{\"total\":" + totalRecords + ",\"rows\":[" + itemAppend + "]}"; json = itemAppend; } return(json); } catch (Exception ex) { return("异常:" + ex.Message); } }
private void Bind() { //查询条件 GetSearch(); List <SmsTemplateInfo> list = null; SmsTemplate bll = new SmsTemplate(); list = bll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray()); rpData.DataSource = list; rpData.DataBind(); htmlAppend += "<div id=\"myDataForPage\" style=\"display:none;\">[{\"PageIndex\":\"" + pageIndex + "\",\"PageSize\":\"" + pageSize + "\",\"TotalRecord\":\"" + totalRecords + "\",\"QueryStr\":\"" + queryStr + "\"}]</div>"; }