本文整理汇总了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);
}
}
示例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");
}
示例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();
}
示例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();
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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");
}
}
示例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>");
}
}
示例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");
}
}
示例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();
}
示例12: gvAssurance_RowDeleting
protected void gvAssurance_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
setAssurancedelete = e.Keys[0].ToString();
mdlpopupmsg.Show();
}
示例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");
}
}
示例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();
}
示例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);
}