前台模版:

    文章列表:{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. ADO.NET中使用事务进行数据库读写的办法

    使用事务一般是进行数据写入,数据读取一般是不需要这货的 第一种办法: 使用存储过程: 顾名思义,在存储过程中定义好变量,定义好事务开始,结束,错误回滚然后在ADO.NET中正常调用存储过程的方法就行 ...

  2. oc-10-函数与方法的区别

    .函数和对象方法的区别 以-开头的方法就是对象方法(即必须实例化对象才能使用的方法) 如: -(void)Run; 区别: ()语法区别,并且对象方法都以-号开头,函数直接以返回值开头 ()对象方法的 ...

  3. sysbench 安装 原创

    1.下载sysbench version 0.5 https://github.com/akopytov/sysbench 2. [root@server1 sysbench-0.5]# pwd/ro ...

  4. SSAS 实例重命名

            在某些时候我们可能想对现有的SSAS实例进行重命名之类的,比如:我以前有两个SSAS,一个2005,一个2008R2,其中我们2005是一开始安装的,并且是默认实例,2008R2是命名 ...

  5. Java_Utils框架

    Spring Utils https://github.com/tangyanbo/springmore

  6. Linux添加快捷启动方式 (Ubuntu Debian CentOS)

    ubuntu桌面快捷方式的创建 debian添加快捷启动方式 centos 6 桌面建立应用程序的快捷方式的方法   今天用着用着ubuntu,突然抽搐了,感觉特别别扭,特别不方便.新装的应用程序不好 ...

  7. 有符号的范围,-128~+127详解(zt)

    这是一个困惑了我几年的问题,它让我对现在的教科书和老师极其不满,从我N年前开始摸电脑时,就几乎在每一本C++教科书上都说,8位有符号的取值范围是-128~+127,为什么不是-127~+127呢,后来 ...

  8. org.apache.hadoop.fs-BlockLocation

    工具类吧 package org.apache.hadoop.fs; import org.apache.hadoop.io.*; //IO包下的类还没涉及到.遇到一个分析一个. import jav ...

  9. Partitioning, Shuffle and sort

    Partitioning, Shuffle and sort  what happened? - Partitioning Partitioning is the process of determi ...

  10. Android ExpandableListView的技巧和问题

    前言: 最近一个多月在认真的学习Android和做项目,文章内容表达的不好或者理解错了,希望大家评论指出. :-) 本文是总结几个比较常用且使用的技巧,和一个大家都会遇到的问题. 文章中大部分语句摘抄 ...