前台:
<asp:Literal ID = "ChiCunShow" runat = "server"></asp:Literal>
后台:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using DataEntity; using System.Data; using BRules; public partial class Manager_CYzhushou_new : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MsgShow.Text= TradeBin(876);//行业主键ID=876。餐饮服务,电商服务,电子商品附ID为876 ChiCunShow.Text = ChiCun(880);//尺寸主键ID=880。具体尺寸(例:100*100)附ID为876 } } public string TradeVal = System.Configuration.ConfigurationManager.AppSettings["TradeVal"].ToString(); public string ChiCunVal = System.Configuration.ConfigurationManager.AppSettings["ChiCunVal"].ToString(); /// <summary> /// 绑定行业 /// </summary> /// <param name="parentid"></param> /// <returns></returns> public string TradeBin(int parentid) { string Returnstr = ""; Tinfodict sTinfodict = TinfodictRules.getonebypk(parentid); DataTable table = TinfodictRules.getonebyparentid(int.Parse(TradeVal)); foreach (DataRow row in table.Rows) { Returnstr += "<li> <a href='#'>" + row["dictname"].ToString() + "</a></li>";//拼接li绑定到Literal } return Returnstr; } /// <summary> /// 绑定尺寸 /// </summary> /// <param name="ChiCunID"></param> /// <returns></returns> public string ChiCun(int ChiCunID) { string returnstr = ""; Tinfodict sTinfodict = TinfodictRules.getonebypk(ChiCunID); DataTable tab = TinfodictRules.getonebyparentid(int.Parse(ChiCunVal)); foreach(DataRow crow in tab.Rows) { returnstr += "<li> <a href='#'>" + crow["dictname"].ToString() + "</a></li>";//拼接li绑定到Literal } return returnstr; } }
web.config配置
<configuration> <appSettings> <!--<add key="excel" value="E:项目派瑞威行新建文件夹gdt_helperwebhelperExcel"/>--> <add key="excel" value="G:/Perry/webhelper/Excel"/> <add key="mailName" value="zhangshuochao@jcteam.cn"/> <add key="mailShowName" value="zhangshuochao@jcteam.cn"/> <add key="mailPwd" value="zhang564335"/> <!--媒体ID--> <add key="MediaVal" value="21"/> <!--行业ID--> <add key="TradeVal" value="876" /> <!--尺寸--> <add key="ChiCunVal" value="880" /> <!--客户ID--> <add key="CustVal" value="21"/> </appSettings> <connectionStrings>