protected void btnComments_Click(object sender, EventArgs e) { if (Session ["user_name"] != null) { if (Page.IsValid) { discussion_comt comt = new discussion_comt(); comt.user_id = int.Parse(Session["user_id"].ToString()); comt.discussion_id = int.Parse(Request.QueryString["id"]); comt.comt_cont = txtComments.Text; comt.comt_time = DateTime.Now; int result = Discussion_comtManager.InsertDiscussion_comt(comt); if (result >= 1) { ScriptManager.RegisterClientScriptBlock(updatecomment, this.GetType(), "click", "alert('评论成功')", true); BindDisComment(); txtComments.Text = ""; } else { ScriptManager.RegisterClientScriptBlock(updatecomment, this.GetType(), "click", "alert('评论失败!')", true); } } } else { ScriptManager.RegisterClientScriptBlock(updatecomment, this.GetType(), "click", "alert('您必须先登录才能评论!')", true); ScriptManager.RegisterStartupScript(updatecomment, updatecomment.GetType(), "updateScript", "window.location.href='login1.aspx'", true); } }
public void BindDisComment() { int id = int.Parse(Request.QueryString["id"]); DataTable dt = Discussion_comtManager.SelectDiscussion_comt(id); if (dt != null && dt.Rows.Count > 0) { LVreply.DataSource = dt; LVreply.DataBind(); } }