div InnerHtml的用法实例
前台:<div id="navigation" runat="server"></div> 例如前台div内的代码为<li><span><span class="span1">运动鞋尺码</span></span>:<a href="#;">40</a><a href="#;">41</a></li> 后台: 先引进using System.Text;然后开始动态从数据库内取值 string sql = ""; DataSet ds = SqlHelper.ExecuteDataset(CommandType.Text, sql); StringBuilder builder = new StringBuilder(); builder.Append("<li><span>运动鞋尺码</span>:"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { builder.Append("<a href="#">"+ ds.Tables[0].Rows[i][0].ToString() + "</a>"); } builder.Append("</li>"); navigation.InnerHtml = builder.ToString(); 这段代码在页面加载时调用
?