示例#1
0
    protected void GridViewExistingUsers_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HiddenField hdnUserASPNETID = (HiddenField)e.Row.FindControl("hdnUserASPNETID");
            LinkButton  lbtnBlockUser   = (LinkButton)e.Row.FindControl("lbtnBlockUser");
            LinkButton  lbtnUnBlockUser = (LinkButton)e.Row.FindControl("lbtnUnBlockUser");

            Guid currentASPNETID = Guid.Parse(hdnUserASPNETID.Value.ToString());
            DictionaryModel.aspnet_Membership userIsApprove = entities.aspnet_Membership.FirstOrDefault(user => user.UserId == currentASPNETID && user.IsApproved == false);

            if (userIsApprove != null)
            {
                lbtnUnBlockUser.Visible = true;
                lbtnBlockUser.Visible   = false;
            }
            else
            {
                lbtnUnBlockUser.Visible = false;
                lbtnBlockUser.Visible   = true;
            }
        }
    }
示例#2
0
    protected void GridViewExistingUsers_ItemCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Sorting")
        {
            LinkButton btn = e.CommandSource as LinkButton;
            if (btn.CommandArgument != SortingColumn)
            {
                SortingDirection = "sortingasc";
            }
            else
            {
                SortingDirection = SortingDirection == "sortingasc" ? "sortingdesc" : "sortingasc";
            }
            SortingColumn = btn.CommandArgument;
            DataBindUsers();
        }
        else if (e.CommandName == "BlockUser" || e.CommandName == "UnBlockUser")
        {
            Guid currentUserASPNETID = Guid.Parse(e.CommandArgument.ToString());

            DictionaryModel.aspnet_Membership currentUser = entities.aspnet_Membership.FirstOrDefault(user => user.UserId == currentUserASPNETID);
            if (currentUser != null)
            {
                if (currentUser.IsApproved)
                {
                    currentUser.IsApproved = false;
                }
                else
                {
                    currentUser.IsApproved = true;
                }

                entities.SaveChanges();
                DataBindUsers();
            }
        }
    }