博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DTcms 扩展字段标签调用
阅读量:5872 次
发布时间:2019-06-19

本文共 4582 字,大约阅读时间需要 15 分钟。

前台模版:

    文章列表:{dr[author]}

    文章内容{model.fields[author]} 点击数

后台CS文件:model.fields["author"].ToString()

 

赋值

Dictionary
dic = new Dictionary
(); dic.Add("good", "1"); dic.Add("author", user.user_name); model.fields = dic; //扩展字段赋值

 

#region 自定义:通过ID获取货号        protected string getGoods_No(int id)        {            string goods_no = "";            Model.article model = new BLL.article().GetModel(id);            List
ls1 = new BLL.article_attribute_field().GetModelList(this.channel_id, ""); foreach (Model.article_attribute_field modelt1 in ls1) { if (modelt1.name == "goods_no") { if (model.fields["goods_no"] != null) goods_no = model.fields["goods_no"].ToString(); } } return goods_no; } #endregion

 

#region 扩展字段赋值=============================        private Dictionary
SetFieldValues(int _channel_id) { DataTable dt = new BLL.article_attribute_field().GetList(_channel_id, "").Tables[0]; Dictionary
dic = new Dictionary
(); foreach (DataRow dr in dt.Rows) { //查找相应的控件 switch (dr["control_type"].ToString()) { case "single-text": //单行文本 TextBox txtControl = FindControl("field_control_" + dr["name"].ToString()) as TextBox; if (txtControl != null) { dic.Add(dr["name"].ToString(), txtControl.Text.Trim()); } break; case "multi-text": //多行文本 goto case "single-text"; case "editor": //编辑器 HtmlTextArea htmlTextAreaControl = FindControl("field_control_" + dr["name"].ToString()) as HtmlTextArea; if (htmlTextAreaControl != null) { dic.Add(dr["name"].ToString(), htmlTextAreaControl.Value); } break; case "images": //图片上传 goto case "single-text"; case "video": //视频上传 goto case "single-text"; case "number": //数字 goto case "single-text"; case "datetime": //时间日期 goto case "single-text"; case "checkbox": //复选框 CheckBox cbControl = FindControl("field_control_" + dr["name"].ToString()) as CheckBox; if (cbControl != null) { if (cbControl.Checked == true) { dic.Add(dr["name"].ToString(), "1"); } else { dic.Add(dr["name"].ToString(), "0"); } } break; case "multi-radio": //多项单选 RadioButtonList rblControl = FindControl("field_control_" + dr["name"].ToString()) as RadioButtonList; if (rblControl != null) { dic.Add(dr["name"].ToString(), rblControl.SelectedValue); } break; case "multi-checkbox": //多项多选 CheckBoxList cblControl = FindControl("field_control_" + dr["name"].ToString()) as CheckBoxList; if (cblControl != null) { StringBuilder tempStr = new StringBuilder(); for (int i = 0; i < cblControl.Items.Count; i++) { if (cblControl.Items[i].Selected) { tempStr.Append(cblControl.Items[i].Value.Replace(',', ',') + ","); } } dic.Add(dr["name"].ToString(), Utils.DelLastComma(tempStr.ToString())); } break; } } return dic; } #endregion

 

转载于:https://www.cnblogs.com/qigege/p/4970036.html

你可能感兴趣的文章
[iOS 10 day by day] Day 2:线程竞态检测工具 Thread Sanitizer
查看>>
Centos/Ubuntu下安装nodejs
查看>>
关于浏览器的cookie
查看>>
Hyper-V 2016 系列教程30 机房温度远程监控方案
查看>>
国内先进的智能移动广告聚合平台-KeyMob聚合
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
PHP - 如何打印函数调用树
查看>>
js闭包
查看>>
寒假。3.3.G - Common Child (最大公共子序)
查看>>
设计模式学习笔记--原型模式
查看>>
.Net 通过MySQLDriverCS操作MySQL
查看>>
JS Cookie
查看>>
ubuntu Unable to locate package sysv-rc-conf
查看>>
笔记:认识.NET平台
查看>>
cocos2d中CCAnimation的使用(cocos2d 1.0以上版本)
查看>>
【吉光片羽】短信验证
查看>>
MacBook如何用Parallels Desktop安装windows7/8
查看>>
gitlab 完整部署实例
查看>>
GNS关于IPS&ASA&PIX&Junos的配置
查看>>