急啊~~留言板回复内容修改问题

zhengyh5339 2009-02-24 04:21:32
前台代码
<asp:DataList ID="DataList_guest" runat="server" style="position: relative; left: 0px; top: 3px;" Height="3px" Width="762px" CellPadding="4" ForeColor="#333333" OnItemDataBound="DataList_guest_ItemDataBound" >
<ItemTemplate>
<div align="left">
留言者:<%# DataBinder.Eval(Container.DataItem,"userName","{0}") %>
留言时间:<%# DataBinder.Eval(Container.DataItem,"postTime","{0}") %>
留言IP:<%# DataBinder.Eval(Container.DataItem,"IP","{0}") %>
</div>
<div align="right">
<asp:LinkButton ID="lbtnreply" runat="server" Style="position: relative" CommandArgument=<%# DataBinder.Eval(Container.DataItem,"ID","{0}") %> OnCommand="lbtnreply_Command">回复留言</asp:LinkButton>
<asp:LinkButton ID="lbtndel" runat="server" Style="position: relative" CommandArgument=<%# DataBinder.Eval(Container.DataItem,"ID","{0}") %> OnCommand="lbtndel_Command">删除留言</asp:LinkButton></div>
<hr />
<font color="#3399cc">
<div align="left">
留言信息:<%# DataBinder.Eval(Container.DataItem,"Contents","{0}") %>
</font>
<hr />
<font color="#cc0099">
回复信息:<%# DataBinder.Eval(Container.DataItem, "reply", "{0}")%><br />
</font></DIV>
</ItemTemplate>

<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<AlternatingItemStyle BackColor="White" />
<ItemStyle BackColor="#FFFBD6" ForeColor="#333333" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
</asp:DataList>

后台绑定 public void databindlist()
{
string query = null;
SqlConnection con = new SqlConnection(com.GetCon());
int curpage = Convert.ToInt32(this.Label1.Text);
con.Open();
SqlDataAdapter sda = new SqlDataAdapter();
query = "select * from guest order by ID DESC";
//query = "select * from guest where id in(select guestid from reverts )";
sda.SelectCommand = new SqlCommand(query, con);
DataSet ds = new DataSet();
sda.Fill(ds, "parent");
query = "select * from reverts r inner join guest g on r.guestid=g.id"; //query = "select * from reverts";
SqlCommand cmd = new SqlCommand(query, con);
sda = new SqlDataAdapter(cmd);
sda.Fill(ds, "child");
ds.Relations.Add("reply", ds.Tables["parent"].Columns["id"], ds.Tables["child"].Columns["guestid"]);
System.Web.UI.WebControls.PagedDataSource ps = new PagedDataSource();
ps.DataSource = ds.Tables["parent"].DefaultView;
ps.AllowPaging = true;
ps.PageSize = 5;
ps.CurrentPageIndex = curpage - 1;
this.btnPre.Enabled = true;
this.btnNext.Enabled = true;

if (curpage == 1)
{
this.btnPre.Enabled = false;
}
if (curpage == ps.PageCount)
{
this.btnNext.Enabled = false;
}

this.DataList_guest.DataSource = ps;
this.DataList_guest.DataBind();
//获取总留言条数
ToatalCountRecord = Convert.ToString(ps.PageCount);
cmd = new SqlCommand("select count(*) from guest", con);
this.Label2.Text = "总留言条数:" + Convert.ToString(cmd.ExecuteScalar()) + "条";
con.Close();

}
是主从表,现在就是回复信息没显示,运行只显示了"System.Data.RelatedView",请各位大虾指点下,谢谢了
...全文
97 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wocake 2009-05-20
  • 打赏
  • 举报
回复
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlCommands1 sc1 = new SqlCommands1();
sc1.upDate();
}
protected void Submit_Click(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
SqlCommands1 sc1 = new SqlCommands1();
sc1.inSert(textbox1.Text.ToString(),textbox2.Text.ToString());
SqlDataReader sdr = sc1.upDate();
rptShow.DataSource = sdr;
rptShow.DataBind();
sdr.Close();
sdr.Dispose();
textbox1.Text = "";
textbox2.Text = "";

}
}
protected void LogOut_Click(object sender, EventArgs e)
{
textbox1.Text = "";
textbox2.Text = "";
}

}
jimu8130 2009-02-25
  • 打赏
  • 举报
回复
ds.Relations.Add("replyid", ds.Tables["parent"].Columns["id"], ds.Tables["child"].Columns["guestid"]);
--------------------------
改下第一个参数的名字或者干脆不要看看
zjybushiren88888 2009-02-25
  • 打赏
  • 举报
回复
友情帮顶个
dawnbear 2009-02-25
  • 打赏
  • 举报
回复
问题归纳的的确不怎么样 这样的代码也看上去乱
以后问问题把问题用文字描述好 如果是找不到代码的错误在哪 也把代码层次感弄的好点发上来
lov52e0 2009-02-24
  • 打赏
  • 举报
回复
看的相当困哪, 建议你以后发帖子问问题的时候,把自己代码放在 插入源代码里面,否则没兴趣看的,,,就此忽略过,,,
Jack2013tong 2009-02-24
  • 打赏
  • 举报
回复
根据主表ID去取子表的内容也可以,不一定要用关系表吧

62,071

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧