protected void BindGrid(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var member = (SnitzMembershipUser)e.Row.DataItem;
            var rankTitle = (Label)e.Row.FindControl("RankTitle");
            var rankStars = (Literal)e.Row.FindControl("RankStars");
            var lckUser = (ImageButton)e.Row.FindControl("lockUser");
            var unlckUser = (ImageButton)e.Row.FindControl("unlockUser");
            var delUser = (ImageButton)e.Row.FindControl("delUser");

            string title = "";
            RankInfo rInf = new RankInfo(member.UserName, ref title, member.Posts, SnitzCachedLists.GetRankings());
            rankTitle.Text = title;
            rankStars.Text = rInf.GetStars();

            if (lckUser != null)
            {
                lckUser.Visible = !member.IsLockedOut;
                lckUser.ToolTip = String.Format(webResources.lblLockUser, member.UserName);
                lckUser.OnClientClick =
                    "confirmPostBack('Do you want to lock the User?','LockMember','" + member.UserName +
                    "');return false;";
                if (unlckUser != null)
                {
                    unlckUser.Visible = member.IsLockedOut;
                    unlckUser.ToolTip = String.Format(webResources.lblUnlockUser, member.UserName);
                    unlckUser.OnClientClick =
                        "confirmPostBack('Do you want to unlock the User?','UnLockMember','" + member.UserName +
                        "');return false;";
                }

                if (delUser != null)
                {
                    delUser.Visible = true;
                    delUser.ToolTip = String.Format(webResources.lblDeleteUser, member.UserName);
                    delUser.OnClientClick =
                        "confirmPostBack('Do you want to delete the User?','DeleteMember','" + member.UserName +
                        "');return false;";
                }
            }
        }
    }
Exemple #2
0
    protected void MgvRowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var member = (MemberInfo)e.Row.DataItem;
            var rankTitle = (Label) e.Row.FindControl("RankTitle");
            var rankStars = (Literal) e.Row.FindControl("RankStars");
            var lckUser = (ImageButton)e.Row.FindControl("lockUser");
            var unlckUser = (ImageButton)e.Row.FindControl("unlockUser");
            var delUser = (ImageButton)e.Row.FindControl("delUser");
            RankInfo rInf;
            try
            {
                string title = "";
                rInf = new RankInfo(member.Username, ref title, member.PostCount, SnitzCachedLists.GetRankings());
                rankTitle.Text = title;
                rankStars.Text = rInf.GetStars();
            }
            catch (Exception)
            {

                throw;
            }

            if ((!IsAdministrator))
            {
                e.Row.Cells.RemoveAt(8);
                e.Row.Cells.RemoveAt(7);
            }
            if (lckUser != null)
            {
                lckUser.Visible = (IsAdministrator) && member.Status == 1;
                lckUser.ToolTip = String.Format(webResources.lblLockUser, member.Username);
                lckUser.OnClientClick =
                    "confirmPostBack('Do you want to lock the User?','LockMember','" + member.Username + "');return false;";
            }
            if (unlckUser != null)
            {
                unlckUser.Visible = (IsAdministrator) && member.Status == 0;
                unlckUser.ToolTip = String.Format(webResources.lblUnlockUser, member.Username);
                unlckUser.OnClientClick =
                    "confirmPostBack('Do you want to unlock the User?','UnLockMember','" + member.Username + "');return false;";
            }

            if (delUser != null)
            {
                delUser.Visible = (IsAdministrator);
                delUser.ToolTip = String.Format(webResources.lblDeleteUser, member.Username);
                delUser.OnClientClick =
                    "confirmPostBack('Do you want to delete the User?','DeleteMember','" + member.Username + "');return false;";
            }
        }
        if(e.Row.RowType == DataControlRowType.Header)
        {
            if ((!IsAdministrator))
            {
                e.Row.Cells.RemoveAt(8);
                e.Row.Cells.RemoveAt(7);
            }
        }
    }