1
我想寫信數據庫中的所有意見,但最後所著的評論..顯示所有評論innerHTML的Asp.net
我的代碼:
public void ShowComments(int id)
{
using (con = new OracleConnection(ConfigurationManager.ConnectionStrings["connectionString"].ToString()))
{
using (cmd = new OracleCommand("select name,comments from comments where id=" + id + "", con))
{
con.Open();
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
comments.InnerHtml = "<br/>" + dr["name"] + ":" + dr["comments"] + "<br/>";
}
con.Close();
}
}
}
寫最後的評論,我希望所有評論寫< DIV> ..
comments.InnerHtml = "<br/>" + dr["name"] + ":" + dr["comments"] + "<br/>";
ASPX:
<div id="comments" runat="server">
</div>
你需要像comments.InnerHtml每次字符串追加到位分配的+ =「你的HTML」 –
是工作,謝謝:) –