前台:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
回复序号:<%#DataBinder.Eval(Container.DataItem, "Number").ToString()%>楼<br />
头像:<asp:Image ID="Image2"
ImageUrl='<%#DataBinder.Eval(Container.DataItem,
"RestImg").ToString()%>' runat="server" />
回复人:<%#DataBinder.Eval(Container.DataItem, "RestUser").ToString()%><br />
回复内容:<%#DataBinder.Eval(Container.DataItem, "RestContent").ToString()%><br />
回复时间:<%#DataBinder.Eval(Container.DataItem, "RestTime").ToString()%><br />
</ItemTemplate>
</asp:Repeater>
后台:
public void BindRest()
{
string Id = "8";
RestoresManager reMana = new RestoresManager();
DataTable dtRest = reMana.SelectRestListBySubjId(Id);
DataTable dt = new DataTable();
dt.Columns.Add("Number", typeof(string));
dt.Columns.Add("RestImg", typeof(string));
dt.Columns.Add("RestUser", typeof(string));
dt.Columns.Add("RestContent", typeof(string));
dt.Columns.Add("RestTime", typeof(string));
for (int i = 0; i < dtRest.Rows.Count; i++)
{
DataRow dr = dt.NewRow();
dr["Number"] = Convert.ToString(i + 1);
dr["RestImg"] = dtRest.Rows[i]["Img"].ToString();
dr["RestUser"] = dtRest.Rows[i]["UserName"].ToString();
dr["RestContent"] = dtRest.Rows[i]["ResContent"].ToString();
dr["RestTime"] = dtRest.Rows[i]["Time"].ToString();
dt.Rows.Add(dr);
}
Repeater1.DataSource = dt;
Repeater1.DataBind();
}