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(); travel_comt_reply reply = new travel_comt_reply(); reply.trcomt_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 = Travel_comt_replyManager.InsertTravel_re(reply); if (result >= 1) { ScriptManager.RegisterClientScriptBlock(updatereply, this.GetType(), "click", "alert('回复成功!')", true); BindTravelComment(); 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 hiddencomid = e.Item.FindControl("HiddenFieldComID") as HiddenField; int trcomt_id = int.Parse(hiddencomid.Value); Repeater rpt = e.Item.FindControl("Rereplycomment") as Repeater; DataTable dt = Travel_comt_replyManager.SelectTravelReply_comt(trcomt_id); if (dt != null && dt.Rows.Count > 0) { rpt.DataSource = dt; rpt.DataBind(); } } }