我想在 div 上显示一个帖子,并在该帖子下显示该帖子的回复,并连续想要显示另一个帖子和回复......我做了这么多,但这并没有显示所需的输出
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class Default3 : System.Web.UI.Page
{
int i = 0;
SqlConnection con = new SqlConnection("server=LOD-PC;uid=sa;pwd=1234;database=db2");
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("select * from t3 ORDER by id DESC", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
i++;
string name = dr["name"].ToString();
string image1 = dr["img"].ToString();
string image2 = image1.Substring(2).ToString();
string id = dr["id"].ToString();
string status = dr["status"].ToString();
string buttonid = i.ToString();
Response.Write("<div id='myDiv' class='myDivClass'> <img src='" + image2 + "' style='width:50px; height:50px; float:left; margin-right:6px;' /> <br/> <br/> <span class='name'> <input id='texta' class='texta' type='text' value=" + name.ToString() + " /> <span/> <span class='id'> <input id='textb' class='textb' type='text' value=" + id.ToString() + " /> <span/> <div id='g'><br/><br/><br/><span class='status'> " + status + " </span> <span class='combutton'> <input id='"+buttonid+"' class='button' type='button' value='Comment'/> </span> </div> </div>");
}
con.Close();
}
}