예제 #1
0
    protected void gvUsers_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        var userID = e.CommandArgument.ToString();

        string roleID  = string.Empty;
        string message = string.Empty;

        if (e.CommandName != "Page")
        {
            GridViewRow  row     = (GridViewRow)((Button)e.CommandSource).NamingContainer;
            int          index   = Convert.ToInt16(row.RowIndex);
            DropDownList ddlRole = (DropDownList)row.FindControl("ddlRole");
            if (ddlRole != null)
            {
                roleID = ddlRole.SelectedItem.Value;

                if (DBWriteManager.UpdateUserRole(userID, roleID) > 0)
                {
                    var user = row.Cells[1].Text + "-" + row.Cells[2].Text + " " + row.Cells[3].Text;
                    message = string.Format("Updated {0}'s role successfully to {1}", user, ddlRole.SelectedItem.Text);
                    MessageBox.Show(message);
                    row.Cells[6].Enabled = false;
                    bindData();
                }
            }
        }
    }