Repeater的显示问题
我有两个表一个是USER 一个是MESS ,USER中实用户的信息 MESS是用户的留言信息表
MESS表中的字段 userid,title,content userid为user表中的相对值
USER表中的字段 userid,username userid为自增长字段
程序是这样的=======================================================
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = connclass.connection();
SqlCommand cmd = new SqlCommand( "select * from bookmess order by id desc ", conn);
showmess.DataSource = cmd.ExecuteReader();
showmess.DataBind();
}
前台是这样的 ======================================== ==============
<asp:Repeater ID= "showmess " runat= "server ">
<ItemTemplate>
//我想在这里把user表中的username显示出来该怎么写呢。也就是把发这条信息的用户名显示出来
标题: <%#DataBinder.Eval(Container.DataItem, "title ") %> <br>
内容: <%#DataBinder.Eval(Container.DataItem, "content ") %>
</ItemTemplate>
</asp:Repeater>
请问该如何写程序呢 谢谢了
------解决方案-------------------- <asp:Repeater ID= "RptReport " DataSource= ' <%# ((DataRowView)Container.DataItem).Row.GetChildRows( "ReportRelation ") %> ' Runat= "server ">
------解决方案--------------------protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = connclass.connection();
SqlCommand cmd = new SqlCommand( "select a.userid,b.username,title,
content from bookmess a join user b on a.userid=b.userid order by a.id desc ", conn);
showmess.DataSource = cmd.ExecuteReader();
showmess.DataBind();
}
前台是这样的 ======================================== ==============
<asp:Repeater ID= "showmess " runat= "server ">