protected void rptAllAlbum_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (Request.QueryString["id"] != null) { string visitedID = Request.QueryString["id"].ToString(); string visitorID = Session["NowUserId"].ToString(); Button btn = (Button)e.Item.FindControl("btnDelAlbum"); string combinedID = btn.CommandArgument.ToString(); SQLOperation sql = new SQLOperation(); DataTable dt = sql.select(" whocansee ", " a_album ", " id=" + combinedID); string limit = dt.Rows[0][0].ToString(); if (limit == "仅好友可见") { if (!helper.onlyFriendsJudge(visitorID, visitedID)) { e.Item.Visible = false; } } else if (limit == "部分好友不可见") { if (!helper.someFriendsCantSee(visitorID, visitedID, combinedID, "相册")) { e.Item.Visible = false; } } else if (limit == "仅自己可见") { e.Item.Visible = false; } } }
} //所有说说的显示--按钮判断 protected void rptStatusShow_ItemDataBound(object sender, RepeaterItemEventArgs e) //评论的数据绑定 { SQLOperation sql = new SQLOperation(); /*当该页面被访问时,不允许访客删除动态*/ if (Request.QueryString["id"] != null) { Button btn = (Button)e.Item.FindControl("btnStatusDel"); btn.Visible = false; string visitedID = Request.QueryString["id"].ToString(); string visitorID = Session["NowUserId"].ToString(); string combinedID = btn.CommandArgument.ToString(); DataTable dt = sql.select(" whocansee ", " a_status ", " id=" + combinedID); string limit = dt.Rows[0][0].ToString(); if (limit == "仅好友可见") { if (!helper.onlyFriendsJudge(visitorID, visitedID)) { e.Item.Visible = false; } } else if (limit == "部分好友不可见") { if (!helper.someFriendsCantSee(visitorID, visitedID, combinedID, "说说")) { e.Item.Visible = false; } } else if (limit == "仅自己可见") { e.Item.Visible = false; } } /*绑定评论的数据*/ if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //找到外层Repeater的数据项 DataRowView rowv = (DataRowView)e.Item.DataItem; //提取外层Repeater的数据项的ID int ID = Convert.ToInt32(rowv["id"]); //找到对应ID下的评论 //string select = "select * from a_comment where commentedid=" + ID.ToString(); //找到内嵌Repeater Repeater rept = (Repeater)e.Item.FindControl("rptInReply"); //数据绑定 rept.DataSource = sql.select(" a_comment.id,a_comment.commentContent, users.nickname ", " users,a_comment ", " a_comment.commentedId= " + ID.ToString() + " and a_comment.kind = 'status' and a_comment.userid = users.id"); rept.DataBind(); } }
protected void rptAllDiaries_ItemDataBound(object sender, RepeaterItemEventArgs e) //为了不让除用户之外的访问者进行操作 { if (Request.QueryString["id"] != null) { int count = rptAllDiaries.Items.Count; for (int i = 0; i < count; i++) { rptAllDiaries.Items[i].FindControl("lkbtnEdit").Visible = false; rptAllDiaries.Items[i].FindControl("btnDel").Visible = false; } Button btn = (Button)e.Item.FindControl("btnDel"); string combinedID = btn.CommandArgument.ToString(); string visitorID = Session["NowUserId"].ToString(); string visitedID = Request.QueryString["id"].ToString(); SQLOperation sql = new SQLOperation(); DataTable dt = sql.select(" whocansee ", " a_diary ", " id=" + combinedID); string limit = dt.Rows[0][0].ToString(); if (limit == "仅好友可见") { if (!helper.onlyFriendsJudge(visitorID, visitedID)) { e.Item.Visible = false; } } else if (limit == "部分好友不可见") { if (!helper.someFriendsCantSee(visitorID, visitedID, combinedID, "日志")) { e.Item.Visible = false; } } else if (limit == "仅自己可见") { e.Item.Visible = false; } } }