protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        Label2.Text = "";
        if (e.CommandName == "Edit")
        {
            lblrole_id.Text = e.CommandArgument.ToString();
            if ((lblrole_id.Text != "1") && (lblrole_id.Text != "2"))
            {
                SqlDataReader dr = obj.Selectrole_id(Int16.Parse(lblrole_id.Text), compid);
                while (dr.Read())
                {
                    txtRole.Text = dr["Role_name"].ToString();
                    if (dr["ActiveDeactive"].ToString() == "True")
                    {
                        // raActive.Checked = true;
                        // raDeactive.Checked = false;
                        ddlstatus.SelectedIndex = ddlstatus.Items.IndexOf(ddlstatus.Items.FindByValue("1"));
                    }
                    else
                    {
                        //raDeactive.Checked = true;
                        //raActive.Checked = false;
                        ddlstatus.SelectedIndex = ddlstatus.Items.IndexOf(ddlstatus.Items.FindByValue("0"));
                    }
                }
                butSubmit.Text    = "Update";
                pnladd.Visible    = true;
                btnadd.Visible    = false;
                lbladd.Text       = "Edit Website Access Rights Role Name";
                CheckBox1.Visible = false;
            }
            else
            {
                Label2.Text = "Sorry, you cannot edit this record.";
            }
        }
        else if (e.CommandName == "Delete")
        {
            lblrole_id.Text = e.CommandArgument.ToString();
            //ModalPopupExtender1222.Show();
            lblrole_id.Visible = false;
            SqlCommand     cmdedit = new SqlCommand("select User_id from User_Role where Role_id='" + Convert.ToString(lblrole_id.Text) + "'", con);
            SqlDataAdapter dtpedit = new SqlDataAdapter(cmdedit);
            DataTable      dtedit  = new DataTable();
            dtpedit.Fill(dtedit);
            if (dtedit.Rows.Count == 0)
            {
                string     str  = "delete from RoleMaster where Role_id='" + Convert.ToString(lblrole_id.Text) + "' ";
                DataSet    ds   = new DataSet();
                SqlCommand cmdd = new SqlCommand(str, con);
                if (con.State.ToString() != "Open")
                {
                    con.Open();
                }
                cmdd.ExecuteNonQuery();
                con.Close();

                fillgrid();
                GridView1.EditIndex = -1;
                Label2.Visible      = true;
                Label2.Text         = "Record deleted successfully";
            }
            else
            {
                Label2.Visible = true;
                Label2.Text    = "You are unable to delete this record. This role is attached to other users. You must transfer all other users to other roles in order to delete this role. Please go to " + "<a href=\"User_Role_Management.aspx\" style=\"font-size:14px; color:red; \" target=\"_blank\">" + "User Role Management " + "</a>page in order to proceed.";
            }
        }
        else if (e.CommandName == "Manage")
        {
            string te = "Page_role_Access.aspx?id=" + e.CommandArgument.ToString();
            ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "window.open('" + te + "');", true);
        }
    }