protected void gvStudent_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { int rowIndex = Convert.ToInt32(e.CommandArgument); GridViewRow row = gvStudent.Rows[rowIndex]; int Id = Convert.ToInt32((row.FindControl("lblId") as Label).Text); string Name = (row.FindControl("lblName") as Label).Text; int DepartmentId = Convert.ToInt32((row.FindControl("lblDepartmentId") as Label).Text); string DepartmentName = (row.FindControl("lblDepartmentName") as Label).Text; StudentDetailBS studentDetailBS = new StudentDetailBS(); ClsStudentResult result = studentDetailBS.ProcessRemove(new StudentDetailBO() { Id = Id, Name = Name, DepartmentId = DepartmentId, DepartmentName = DepartmentName }); if (result.Success) { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Student Name: " + Name + "');", true); } else { ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + result.ErrorDesc + "');", true); } } }
public void DeleteStudent() { int Id = 1; string Name = "Preethi"; int DepartmentId = 1; string DepartmentName = "Physics"; StudentDetailBS studentDetailBS = new StudentDetailBS(); ClsStudentResult result = studentDetailBS.ProcessRemove(new StudentDetailBO() { Id = Id, Name = Name, DepartmentId = DepartmentId, DepartmentName = DepartmentName }); }