本文介绍了生成div标签运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想在div中显示多条记录。所以我希望每一行都会显示在一个新的div中, 如何在每条记录上生成新的div。 请帮帮我 提前谢谢i want to show multiple records in div. so i want each row will be shown in a new div,how to generate new div on each record.please help methanks in advance推荐答案System.Web.UI.HtmlControls.HtmlGenericControl divName = new HtmlGenericControl("div");Panel1.Controls.Add(divName); 希望它可以帮助你:)hope it helps you :)<pre lang="text">protected void btnCode_Click(object sender, EventArgs e){ System.Web.UI.HtmlControls.HtmlGenericControl dynDiv = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV"); dynDiv.ID = "dynDivCode"; dynDiv.Style.Add(HtmlTextWriterStyle.BackgroundColor, "Gray"); dynDiv.Style.Add(HtmlTextWriterStyle.Height, "20px"); dynDiv.Style.Add(HtmlTextWriterStyle.Width, "300px"); dynDiv.InnerHtml = "I was created using Code Behind"; this.Controls.Add(dynDiv);} 这篇关于生成div标签运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-12 01:29