当前位置: 首页>>代码示例>>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;未经允许,请勿转载。