當前位置: 首頁>>代碼示例>>C#>>正文


C# WebControls.GridViewDeleteEventArgs類代碼示例

本文整理匯總了C#中System.Web.UI.WebControls.GridViewDeleteEventArgs的典型用法代碼示例。如果您正苦於以下問題:C# GridViewDeleteEventArgs類的具體用法?C# GridViewDeleteEventArgs怎麽用?C# GridViewDeleteEventArgs使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GridViewDeleteEventArgs類屬於System.Web.UI.WebControls命名空間,在下文中一共展示了GridViewDeleteEventArgs類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: grdStudents_RowDeleting

        protected void grdStudents_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                //connect
                using (DefaultConnectionEF conn = new DefaultConnectionEF())
                {
                    //get the Department Id
                    Int32 StudentID = Convert.ToInt32(grdStudents.DataKeys[e.RowIndex].Values["StudentID"]);

                    var s = (from stud in conn.Students
                             where stud.StudentID == StudentID
                             select stud).FirstOrDefault();

                    //process the delete
                    conn.Students.Remove(s);
                    conn.SaveChanges();

                    //update the grid
                    GetStudents();
                }
            }
            catch (System.IO.IOException e2)
            {
                Server.Transfer("/error.aspx", true);
            }
        }
開發者ID:HadenHiles,項目名稱:ASP-OngoingLesson,代碼行數:27,代碼來源:students.aspx.cs

示例2: GridView1_RowDeleting

 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     int id = (int)GridView1.DataKeys[e.RowIndex].Value;
     workStation = dataWorkStation.readWorkStationEDIT(id);
     dataWorkStation.deleteWorkStation(id, workStation.IdLab);
     Response.Redirect("/CRUDWorkStation.aspx");
 }
開發者ID:jedelsan,項目名稱:LabControlv3,代碼行數:7,代碼來源:CRUDWorkStation.aspx.cs

示例3: GridView1_RowDeleting

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            SqlConnection con = new SqlConnection(connectionString);
            con.Open();
            int a = e.RowIndex;
            GridViewRow r = GridView1.Rows[a];
            string  x = r.Cells[1].Text;

            string q = "SELECT UsuarioId FROM Usuarios WHERE UsuarioNombre='"+x+"'";

            SqlDataAdapter adp = new SqlDataAdapter(q, con);
            DataTable tb = new DataTable();
            adp.Fill(tb);

            string id="";
            foreach (DataRow row in tb.Rows)
            {
                id = row[0].ToString();
            }

            q = "DELETE RolesXUsuario WHERE UsuarioId='" + id + "'";

            SqlCommand cmd = new SqlCommand(q, con);
            cmd.ExecuteNonQuery();

            con.Close();
        }
開發者ID:kingtrocko,項目名稱:EticaUNITEC,代碼行數:27,代碼來源:Usuarios.aspx.cs

示例4: GridView1_RowDeleting

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if ((sender as GridView).Rows.Count > 1)
            {
                int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString());

                var delTest = from test in _eJDataContext.Tests.ToList()
                              where test.Id == id
                              select test;
                _eJDataContext.Tests.DeleteOnSubmit(delTest.First());
                try
                {
                    _eJDataContext.SubmitChanges();
                }
                catch
                {
                    _eJDataContext.ChangeConflicts.ResolveAll(RefreshMode.KeepChanges);
                    {
                        try
                        {
                            _eJDataContext.SubmitChanges();
                        }
                        catch (Exception exept)
                        {
                            Console.WriteLine("Error:  " + exept);
                        }
                    }
                }

                FillCustomerInGrid();
            }
        }
開發者ID:BeliaevIlia,項目名稱:CompetenceManager,代碼行數:32,代碼來源:EditTests.aspx.cs

示例5: m_grid_RowDeleting

        protected void m_grid_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                //int id = e.RowIndex;
                //m_grid.EditIndex = id;

                //Guid delId = new Guid(m_grid.DataKeys[e.RowIndex].Value.ToString());
                //if (m_grid.DataKeys[e.RowIndex].Value.ToString() != "")
                //{
                //    clsKho objKho = new clsKho();
                //    objKho.Kho_Id = m_grid.DataKeys[e.RowIndex].Value.ToString();
                //    int status_Delete = objKho.Delete();
                //    if (status_Delete == 1)
                //    {

                //    }
                //    if (status_Delete <= 0)
                //    {

                //    }
                //}
            }
            catch (Exception ex)
            {

            }
            bindData(-1);
        }
開發者ID:chutinhha,項目名稱:web-quan-ly-kho,代碼行數:29,代碼來源:ThongTinThietBi.aspx.cs

示例6: grdHomeProducts_RowDeleting

 private void grdHomeProducts_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     if (VShopHelper.RemoveHomeTopic((int) this.grdHomeTopics.DataKeys[e.RowIndex].Value))
     {
         base.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
     }
 }
開發者ID:ZhangVic,項目名稱:asp1110git,代碼行數:7,代碼來源:HomeTopicSetting.cs

示例7: grdStudents_RowDeleting

        protected void grdStudents_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //store which row was clicked
            Int32 selectedRow = e.RowIndex;

            //get the selected StudentID using the grid's Data Key collection
            Int32 StudentID = Convert.ToInt32(grdStudents.DataKeys[selectedRow].Values["StudentID"]);
            try
            {
                //use EF to remove the selected student from the db
                using (DefaultConnectionEF db = new DefaultConnectionEF())
                {

                    Student s = (from objS in db.Students
                                 where objS.StudentID == StudentID
                                 select objS).FirstOrDefault();

                    //do the delete
                    db.Students.Remove(s);
                    db.SaveChanges();
                }
            }
            catch (System.Data.SqlClient.SqlException e1)
            {
                Server.Transfer("/error.aspx", true);
            }
            catch (System.Data.Entity.Core.EntityException e1)
            {
                Server.Transfer("/error.aspx", true);
            }

            //refresh the grid
            GetStudents();
        }
開發者ID:ConnorX,項目名稱:lab4,代碼行數:34,代碼來源:students.aspx.cs

示例8: grdStudents_RowDeleting

        protected void grdStudents_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            // identify the department id to be deleted from the row the user selected
            Int32 StudentID = Convert.ToInt32(grdStudents.DataKeys[e.RowIndex].Values["StudentID"]);
            try
            {
             //connect
            using (DefaultConnection db = new DefaultConnection())
            {
                Student stud = (from s in db.Students
                                where s.StudentID == StudentID
                                select s).FirstOrDefault();

                // delete
                db.Students.Remove(stud);
                db.SaveChanges();

                //refresh the grid
                GetStudents();
            }
            }
            catch
            {
                Response.Redirect("~/error.aspx");
            }
        }
開發者ID:tlouth19,項目名稱:lab4,代碼行數:26,代碼來源:students.aspx.cs

示例9: GridView1_RowDeleting

 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         objdept.ID = Convert.ToInt32(this.GridView1.DataKeys[e.RowIndex].Value);
         DataTable dtDept = dept.SelectDepartmentByID(objdept);
         employee emp = new employee();
         MEmployee objemp = new MEmployee();
         objemp.Dept = dtDept.Rows[0]["name"].ToString();
         DataTable dtEmp = emp.SelectEmployeeByDept(objemp);
         if (dtEmp.Rows.Count > 0)
         {
             string myscript = @"alert('此部門內尚有員工,不能刪除!');";
             Page.ClientScript.RegisterStartupScript(this.GetType(), "myscript", myscript, true);
         }
         else
         {
             dept.DeleteDepartmentByID(objdept);
         }
         GridView1.DataSource = dept.SelectAllDepartment();
         GridView1.DataBind();
     }
     catch (Exception ex)
     {
         this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + ex.Message + "');</script>");
     }
 }
開發者ID:wangchuncheng211,項目名稱:OAS,代碼行數:27,代碼來源:BaseDepartmentManager.aspx.cs

示例10: grdCourses_RowDeleting

        protected void grdCourses_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //get selected course ID
            Int32 CourseID = Convert.ToInt32(grdCourses.DataKeys[e.RowIndex].Values["CourseID"]);
            try
            {
                using (comp2007Entities db = new comp2007Entities())
                {
                    //get selected course
                    Course objC = (from c in db.Courses
                                   where c.CourseID == CourseID
                                   select c).FirstOrDefault();

                    //delete
                    db.Courses.Remove(objC);
                    db.SaveChanges();

                    //refresh grid
                    GetCourses();
                }
            }
            catch (Exception q)
            {
                Response.Redirect("~/error.aspx");
            }
        }
開發者ID:JamesIsNinja,項目名稱:comp2007lab4,代碼行數:26,代碼來源:courses.aspx.cs

示例11: grdContact_RowDeleting

 protected void grdContact_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     int id = Convert.ToInt32(commentsGrid.DataKeys[e.RowIndex].Values[0].ToString());
     var comment = new Comment(id);
     comment.Delete();
     FillGrid();
 }
開發者ID:nul800sebastiaan,項目名稱:OurUmbraco,代碼行數:7,代碼來源:ForumSpamCleaner.ascx.cs

示例12: gvAssurance_RowDeleting

        protected void gvAssurance_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            setAssurancedelete = e.Keys[0].ToString();
            mdlpopupmsg.Show();


        }
開發者ID:AppCPC,項目名稱:WebComSci,代碼行數:7,代碼來源:SearchAssurance.aspx.cs

示例13: grdActivities_RowDeleting

        protected void grdActivities_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                using (DefaultConnectionAL conn = new DefaultConnectionAL())
                {
                    var user = HttpContext.Current.GetOwinContext().Authentication.User.Identity.GetUserId();

                    Int32 ActivityID = Convert.ToInt32(grdActivities.DataKeys[e.RowIndex].Values["id"]);

                    var activityItem = (from a in conn.activities
                             where a.id == ActivityID
                             select a).FirstOrDefault();
                    //save
                    conn.activities.Remove(activityItem);
                    conn.SaveChanges();

                    //redirect to updated departments page
                    GetActivities();
                }
            }
            catch (Exception e2)
            {
                Response.Redirect("~/error.aspx");
            }
        }
開發者ID:HadenHiles,項目名稱:activity-logger,代碼行數:26,代碼來源:activitylog.aspx.cs

示例14: GrdCamera_RowDeleting

 protected void GrdCamera_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     //int selectedRow = e.RowIndex;
     //Label FacilityID = (Label)grdCamera.Rows[selectedRow].FindControl("cameraID1");
     //string facilityID = FacilityID.Text;
      // BindGridView();
 }
開發者ID:133332D,項目名稱:FYPJ-PROJECT,代碼行數:7,代碼來源:ModuleSearch.aspx.cs

示例15: grDS_RowDeleting

 protected void grDS_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     int madv = int.Parse(grDS.DataKeys[e.RowIndex].Value.ToString());
     dv.XoaDonVi(madv);
     int ma = int.Parse(drNBH.SelectedValue);
     loadDS(ma);
 }
開發者ID:baotiit,項目名稱:savvyplatform,代碼行數:7,代碼來源:QuanLyDonViBaoHiem.aspx.cs


注:本文中的System.Web.UI.WebControls.GridViewDeleteEventArgs類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。