前台模版:

    文章列表:{dr[author]}

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

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

赋值

 Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("good", "");
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<Model.article_attribute_field> 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<string, string> SetFieldValues(int _channel_id)
{
DataTable dt = new BLL.article_attribute_field().GetList(_channel_id, "").Tables[];
Dictionary<string, string> dic = new Dictionary<string, string>();
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(), "");
}
else
{
dic.Add(dr["name"].ToString(), "");
}
}
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 = ; 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

DTcms 扩展字段标签调用的更多相关文章

  1. 如何在调用Marketing Cloud contact创建API时增加对扩展字段的支持

    需求:扩展字段"微信ID"是我创建出来的extension field,我想用Marketing Cloud提供的contact creation API,在创建contact时也 ...

  2. dedecms搜索模板,使用{dede:list}标签调用自定义字段不显示(空白)

    前几天使用织梦做一个搜索功能,正常使用{dede:list}调用自定义内容模型中的自定义字段,代码如下:(自定义字段的调用可以参考:http://www.dede58.com/a/dedejq/523 ...

  3. DEDECMS标签调用汇总啊

    非常有用的标签调用的方法 关键描述调用标签: <meta name="keywords" content="{dede:field name='keywords'/ ...

  4. 使用BAPI_ACC_DOCUMENT_POST,创建会计凭证,用BADI扩展字段(转)

    业务需求:和银行做一个接口,要通过银行流水产生会计凭证,会计凭证的事务码是F-02,查到了BAPI方法BAPI_ACC_DOCUMENT_POST.昨天测试发现,有一些参数在BAPI_ACC_DOCU ...

  5. dede标签调用

    关键描述调用标签: <meta name="keywords" content="{dede:field name='keywords'/}">&l ...

  6. 使用WCF扩展记录服务调用时间

    随笔- 64  文章- 0  评论- 549  真实世界:使用WCF扩展记录服务调用时间   WCF 可扩展性 WCF 提供了许多扩展点供开发人员自定义运行时行为. WCF 在 Channel Lay ...

  7. 用Dedecms5.7的arclist标签调用文章内容

    arclist标签调用文章内容 首先大家都知道在Dedecms中,list标签是可以调用文章内容的,调用格式就不再此冗述了.从我个人来说,我非常不喜欢用list标签调用,有可能我会尽量使用arclis ...

  8. dedecms利用memberlist标签调用自定义会员模型的会员信息

    [摘要]本文讲一下dedecms如何利用memberlist标签调用自定义会员模型的会员信息. dedecms利用memberlist标签调用自定义会员模型的会员信息,这个问题找了很久,官方论坛提问过 ...

  9. golang自定义struct字段标签

    原文链接: https://sosedoff.com/2016/07/16/golang-struct-tags.html struct是golang中最常使用的变量类型之一,几乎每个地方都有使用,从 ...

随机推荐

  1. dup和dup2函数

    下面两个函数都可用来复制一个现存的文件描述符: #include<unistd.h> int dup(int filedes); int dup2(int filedes,int file ...

  2. VirtualBOX 虚拟机安装 OS X 10.9 Mavericks 及 Xcode 5,本人X220亲测

    原文链接:http://bbs.weiphone.com/read-htm-tid-7625465.html 建议电脑要求    Windows 7/8, 32 / 64 bit    CPU Int ...

  3. Swiper Usage&&API

    最近使用Swipe.js,发现中文的资料很少,试着翻译了一下.能力有限,翻译难免错漏,请指出,多谢!如果想获得国外较多而全的文档,还是用google. 一了解SwiperSwiper 是一款免费以及轻 ...

  4. Opacity多浏览器透明度兼容处理(转)

    用来设定元素透明度的 Opacity 是CSS 3里的一个属性.当然现在还只有少部分浏览器支持. 不过各个浏览器都有自己的私有属性来支持,其中包括老版本的Mozilla和Safari: IE: fil ...

  5. BestCoder Sequence

    hdu  4908  Bestcoder Problem Description Mr Potato is a coder.Mr Potato is the BestCoder. One night, ...

  6. python(3)-内置函数

    >>> abs(-1) #绝对值,小数也可以,不能是其它字符 1 >>> all([1,2,3,4,5,6,7]) #如果传入的列表所有元素都为真,则True Tr ...

  7. IC卡写卡操作流程

    var icData = new ICData(); var deviceResult = crd.CRDICPowerOn(); if (!deviceResult.IsSuccess) retur ...

  8. cvSaveImage的第三个参数

    http://stackoverflow.com/questions/801054/opencv-cvsaveimage-jpeg-compression-factor   #define CV_IM ...

  9. Radware中APPDirector系列的Farm Table中的session mode参数说明

    Session mode中共有5种会话保持方式:1.Regular,是普通的会话保持,形成的表项是:Client ip+Server ip的形式2.EntryPerSession(EPS),是端口与i ...

  10. Java MongoDB Driver 3.x - Quick Start

    Maven Dependency: <dependency> <groupId>org.mongodb</groupId> <artifactId>mo ...