/// <summary>
    /// /added by vishal 30-05-2012
    /// </summary>
    protected void btnMapAll_Click(object sender, EventArgs e)
    {
        UserEmail obj1 = new UserEmail();
        DataTable dt   = BindGridMapAll();

        if (dt != null)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["Emailid"].ToString() != "")
                {
                    objuseremail.Userid  = Convert.ToInt32(dt.Rows[i]["Userid"]);
                    objuseremail.Emailid = dt.Rows[i]["Emailid"].ToString();
                    obj1 = obj1.Get_By_id(objuseremail.Userid);
                    if (obj1.Userid != objuseremail.Userid)
                    {
                        objuseremail.Insert();
                    }
                    if (obj1.Active == 0)
                    {
                        obj1.Active  = 1;
                        obj1.Userid  = objuseremail.Userid;
                        obj1.Emailid = objuseremail.Emailid;
                        obj1.Update();
                    }
                }
            }
            BindGrid();
            string myScript;
            myScript = "<script language=javascript>alert('All user mapping successfully !');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void grdvwSite_RowDataBound(Object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            ////////////////////////////meenakshi
            if ((e.Row.Cells[1].Text) != "&nbsp;")
            {
                /////////////////end
                int userid = Convert.ToInt32(e.Row.Cells[1].Text);


                UserEmail objemail   = new UserEmail();
                CheckBox  myCheckBox = (CheckBox)e.Row.FindControl("CheckAll");
                //CheckBox myCheckBox = new CheckBox();
                objemail = objemail.Get_By_id(userid);
                if (objemail.Userid == userid)
                {
                    if (objemail.Active == 1)
                    {
                        // myCheckBox.Checked = true;
                        myCheckBox.Checked = true;
                    }
                    else
                    {
                        myCheckBox.Checked = false;
                    }
                }
            }
        }
    }
    protected void btnreject_Click(object sender, EventArgs e)
    {
        DataTable dtMealTemplate = new DataTable();


        dtMealTemplate.Columns.Add("Userid", Type.GetType("System.Int32"));
        dtMealTemplate.Columns.Add("Emailid", Type.GetType("System.String"));
        foreach (GridViewRow gvr in grdvwSite.Rows)
        {
            ///DataRow drMT = new DataRow();

            DataRow drMT = dtMealTemplate.NewRow();
            drMT["Userid"]  = gvr.Cells[1].Text;
            drMT["Emailid"] = gvr.Cells[4].Text;

            dtMealTemplate.Rows.Add(drMT);
            CheckBox myCheckBox = (CheckBox)gvr.FindControl("CheckAll");
            if (myCheckBox.Checked == false)
            {
                UserEmail obj1 = new UserEmail();

                objuseremail.Userid  = Convert.ToInt32(drMT["Userid"]);
                objuseremail.Emailid = drMT["Emailid"].ToString();
                objuseremail.Active  = 0;
                obj1 = obj1.Get_By_id(objuseremail.Userid);
                if (obj1.Userid == objuseremail.Userid)
                {
                    objuseremail.Update();
                }
            }
        }
    }
    protected void btnreject_Click(object sender, EventArgs e)
    {
        DataTable dtMealTemplate = new DataTable();

        dtMealTemplate.Columns.Add("Userid", Type.GetType("System.Int32"));
        dtMealTemplate.Columns.Add("Emailid", Type.GetType("System.String"));
        foreach (GridViewRow gvr in grdvwSite.Rows)
        {
        ///DataRow drMT = new DataRow();

        DataRow drMT = dtMealTemplate.NewRow();
        drMT["Userid"] = gvr.Cells[1].Text;
        drMT["Emailid"] = gvr.Cells[4].Text;

        dtMealTemplate.Rows.Add(drMT);
        CheckBox myCheckBox = (CheckBox)gvr.FindControl("CheckAll");
        if (myCheckBox.Checked == false)
        {
            UserEmail obj1 = new UserEmail();

            objuseremail.Userid = Convert.ToInt16(drMT["Userid"]);
            objuseremail.Emailid = drMT["Emailid"].ToString();
            objuseremail.Active = 0;
            obj1 = obj1.Get_By_id(objuseremail.Userid);
            if (obj1.Userid == objuseremail.Userid)
            {
                objuseremail.Update();
            }
        }
        }
    }
 /// <summary>
 /// /added by vishal 30-05-2012
 /// </summary>
 protected void btnMapAll_Click(object sender, EventArgs e)
 {
     UserEmail obj1 = new UserEmail();
     DataTable dt = BindGridMapAll();
     if (dt != null)
     {
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             if (dt.Rows[i]["Emailid"].ToString() != "")
             {
                 objuseremail.Userid = Convert.ToInt32(dt.Rows[i]["Userid"]);
                 objuseremail.Emailid = dt.Rows[i]["Emailid"].ToString();
                 obj1 = obj1.Get_By_id(objuseremail.Userid);
                 if (obj1.Userid != objuseremail.Userid)
                 {
                     objuseremail.Insert();
                 }
                 if (obj1.Active == 0)
                 {
                     obj1.Active = 1;
                     obj1.Userid = objuseremail.Userid;
                     obj1.Emailid = objuseremail.Emailid;
                     obj1.Update();
                 }
             }
         }
         BindGrid();
         string myScript;
         myScript = "<script language=javascript>alert('All user mapping successfully !');</script>";
         Page.RegisterClientScriptBlock("MyScript", myScript);
         return;
     }
 }
    protected void grdvwSite_RowDataBound(Object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int userid = Convert.ToInt32(e.Row.Cells[1].Text);
            UserEmail objemail = new UserEmail();
            CheckBox myCheckBox = (CheckBox)e.Row.FindControl("CheckAll");
            //CheckBox myCheckBox = new CheckBox();
            objemail = objemail.Get_By_id(userid);
            if (objemail.Userid == userid)
            {
                if (objemail.Active == 1)
                {

                    // myCheckBox.Checked = true;
                    myCheckBox.Checked = true;

                }
                else
                {

                    myCheckBox.Checked = false;
                }
            }
        }
    }