• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# WebControls.GridViewDeleteEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Web.UI.WebControls.GridViewDeleteEventArgs的典型用法代码示例。如果您正苦于以下问题:C# GridViewDeleteEventArgs类的具体用法?C# GridViewDeleteEventArgs怎么用?C# GridViewDeleteEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GridViewDeleteEventArgs类属于System.Web.UI.WebControls命名空间,在下文中一共展示了GridViewDeleteEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: grdCourses_RowDeleting

        protected void grdCourses_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Int32 CourseID = Convert.ToInt32(grdCourses.DataKeys[e.RowIndex].Values["CourseID"]);

            using (comp2007Entities db = new comp2007Entities())
            {
                // Check for any enrollments in the course to be deleted, and remove them. Otherwise, it'll
                // throw a foreign key exception
                foreach (Enrollment en in db.Enrollments)
                {
                    if (en.CourseID == CourseID)
                    {
                        db.Enrollments.Remove(en);
                    }
                }

                // Find the selected course
                Course c = (from objS in db.Courses
                            where objS.CourseID == CourseID
                            select objS).FirstOrDefault(); // Using First would get an error if no data comes back, FirstOrDefault won't throw an error

                // Do the delete
                db.Courses.Remove(c);
                db.SaveChanges();

                //Refresh the data on the page
                GetDepartment();
            }
        }
开发者ID:Itniraan,项目名称:COMP2007_Lab03,代码行数:29,代码来源:department.aspx.cs


示例17: grdDepartments_RowDeleting

        protected void grdDepartments_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //identify the DepartmentID to be deleted from the row the user selected
            Int32 DepartmentID = Convert.ToInt32(grdDepartments.DataKeys[e.RowIndex].Values["DepartmentID"]);
            try
            {
                //connect
                using (DefaultConnection db = new DefaultConnection())
                {
                    Department dep = (from d in db.Departments
                                      where d.DepartmentID == DepartmentID
                                      select d).FirstOrDefault();

                    //delete
                    db.Departments.Remove(dep);
                    db.SaveChanges();

                    //refresh grid
                    GetDepartments();

                }
            }
            catch (Exception ex)
            {
                Response.Redirect("error.aspx");

            }
        }
开发者ID:vatcheati,项目名称:lab4,代码行数:28,代码来源:departments.aspx.cs


示例18: gvBooks_RowDeleting

 protected void gvBooks_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     GridViewRow row = gvBooks.Rows[e.RowIndex];
        TextBox txtDelete=(TextBox)row.Cells[0].Controls[0];
       BookOperation.DeleteBook(txtDelete.Text);
     gvBind();
 }
开发者ID:jaskarans-optimus,项目名称:Induction,代码行数:7,代码来源:BookDetails.aspx.cs


示例19: grdStudents_RowDeleting

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

                //get the selected sudent ID using the grids data key collection
                Int32 StudentID = Convert.ToInt32(grdStudents.DataKeys[selectedRow].Values["StudentID"]);

                //use entity to find the object and remove it
                using (GetWreckedEntities db = new GetWreckedEntities())
                {
                    Student s = (from objs in db.Students where objs.StudentID == StudentID select objs).FirstOrDefault();

                    //now we need to do the delete
                    db.Students.Remove(s);
                    db.SaveChanges();
                }
                //refresh the grid
                getStudents();
            }
            catch (System.Exception)
            {
                Response.Redirect("/Error.aspx");
            }
        }
开发者ID:Leathel,项目名称:Lesson12,代码行数:27,代码来源:students.aspx.cs


示例20: gvCustomFees_RowDeleting

        protected void gvCustomFees_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (this.Request["x"] != null && this.Request["y"] != null)
            {
                gvCustomFees.EditIndex = -1;
                RefreshFeeGrid();
            }
            else
            {

                int customFeeId = (int)gvCustomFees.DataKeys[e.RowIndex].Value;

                var fee = new CustomFee(customFeeId);

                var response = InvoicingService.RemoveCustomFee(fee);
                if (response.IsSuccessful)
                {
                    gvCustomFees.EditIndex = -1;
                    RefreshFeeGrid();

                    UserMessage.SetSuccess("Custom Fee deleted.");
                }
                else
                {
                    UserMessage.SetFailure(response.Message);
                }
            }
        }
开发者ID:robgray,项目名称:Tucana,代码行数:28,代码来源:CustomFees.aspx.cs



注:本文中的System.Web.UI.WebControls.GridViewDeleteEventArgs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WebControls.GridViewDeletedEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# WebControls.GridViewCommandEventArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap