protected void btnreply_Click(object sender, EventArgs e) { if (Session ["user_name"] != null) { if (Page.IsValid) { Button btn = (Button)sender; string a = ((TextBox)btn.Parent.FindControl("txtreply")).Text.Trim(); discussion_reply reply = new discussion_reply(); reply.discomt_id = Int32.Parse((btn.Parent.FindControl("HiddenFieldComID") as HiddenField).Value); reply.user_id = int.Parse(Session["user_id"].ToString()); reply.reply_cont = ((TextBox)btn.Parent.FindControl("txtreply")).Text.Trim(); reply.reply_time = DateTime.Now; int result = Discussion_replyManager.Insert(reply); if (result >= 1) { ScriptManager.RegisterClientScriptBlock(updatereply, this.GetType(), "click", "alert('回复成功!')", true); BindDisComment(); txtComments.Text = ""; } else { ScriptManager.RegisterClientScriptBlock(updatereply, this.GetType(), "click", "alert('回复失败!')", true); } } } else { ScriptManager.RegisterClientScriptBlock(updatereply, this.GetType(), "click", "alert('您必须先登录才能回复!')", true); ScriptManager.RegisterStartupScript(updatereply, updatereply.GetType(), "updateScript", "window.location.href='login1.aspx'", true); } }
protected void LVreply_ItemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { HiddenField hiddencomtid = e.Item.FindControl("HiddenFieldComID") as HiddenField; int discomt_id = int.Parse(hiddencomtid.Value); Repeater re = e.Item.FindControl("Rereplycomment") as Repeater; DataTable dt = Discussion_replyManager.SelectDiscussion_re(discomt_id); if (dt != null && dt.Rows.Count > 0) { re.DataSource = dt; re.DataBind(); } } }