protected void gvInt_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = (GridViewRow)gvInt.Rows[e.RowIndex]; List <string> LstInst = new List <string>(); Label lblInstID = (gvInt.Rows[e.RowIndex].FindControl("lblInstID") as Label); LstInst.Add(lblInstID.Text); TextBox txtInstName = (TextBox)row.Cells[1].Controls[0]; LstInst.Add(txtInstName.Text); LstInst.Add((gvInt.Rows[e.RowIndex].FindControl("ddlDept") as DropDownList).SelectedItem.Value); TextBox txtPhNum = (TextBox)row.Cells[3].Controls[0]; if (CheckRegex("^[0-9-]*$", txtPhNum.Text) == false) { Page.ClientScript.RegisterStartupScript(this.GetType(), "AlertScript", "AlertBox('Invalid Phone#')", true); return; } LstInst.Add(txtPhNum.Text); TextBox txtEmailID = (TextBox)row.Cells[4].Controls[0]; if (CheckRegex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$", txtEmailID.Text) == false) { Page.ClientScript.RegisterStartupScript(this.GetType(), "AlertScript", "AlertBox('Invalid Email ID')", true); return; } LstInst.Add(txtEmailID.Text); ViewState["LstInst"] = LstInst.ToArray(); ODS_Inst.Update(); gvInt.EditIndex = -1; Page.ClientScript.RegisterStartupScript(this.GetType(), "AlertScript", "AlertBox('Record Updated Successfully')", true); }
protected void gvInt_RowDeleting(object sender, GridViewDeleteEventArgs e) { Label lblInstID = (gvInt.Rows[e.RowIndex].FindControl("lblInstID") as Label); ViewState["DelInstID"] = lblInstID.Text; ODS_Inst.Delete(); gvInt.EditIndex = -1; Page.ClientScript.RegisterStartupScript(this.GetType(), "AlertScript", "AlertBox('Record Deleted Successfully')", true); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Cache[ODS_Inst.CacheKeyDependency] = "InstCache"; //ViewState["blIsSearch"] = false; ODS_Inst.Select(); } }
protected void btnAdd_Click(object sender, EventArgs e) { if (Page.IsValid) { BusinessObjects bo = new BusinessObjects(); int retValue = bo.CheckDupUser(txtUserID.Text); if (retValue > 0) { ViewState["UserState"] = "Instructor ID already exists"; Page.Validate(); } else { //Add user //ViewState["blIsSearch"] = false; ODS_Inst.Insert(); ODS_Inst.Select(); ResetFields(); Page.ClientScript.RegisterStartupScript(this.GetType(), "AlertScript", "AlertBox('Instructor Created Successfully')", true); } } }
protected void gvInt_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e) { gvInt.EditIndex = -1; //ViewState["blIsSearch"] = false; ODS_Inst.Select(); }
protected void gvInt_RowEditing(object sender, GridViewEditEventArgs e) { gvInt.EditIndex = e.NewEditIndex; //ViewState["blIsSearch"] = false; ODS_Inst.Select(); }