public void BindOfferGrid() { OffersBLogic oOfferBL = new OffersBLogic(); gvOfferDetails.DataSource = oOfferBL.GetOffer(); gvOfferDetails.DataBind(); }
protected void gvOfferDetails_RowUpdating(object sender, GridViewUpdateEventArgs e) { Offers oOffers = new Offers(); OffersBLogic oOffersBL = new OffersBLogic(); Label tmpofferId = (Label)gvOfferDetails.Rows[e.RowIndex].FindControl("lblEditoffferID"); TextBox tmpEOfferText = (TextBox)gvOfferDetails.Rows[e.RowIndex].FindControl("txtEditOfferText"); TextBox tmpEOfferlink = (TextBox)gvOfferDetails.Rows[e.RowIndex].FindControl("txtEditOfferLink"); TextBox tmpEValidity = (TextBox)gvOfferDetails.Rows[e.RowIndex].FindControl("txtEditValidity"); if (tmpofferId != null) { oOffers.OfferID = tmpofferId.Text; oOffers.OfferText = tmpEOfferText.Text; oOffers.OfferLink = tmpEOfferlink.Text; oOffers.Validity = int.Parse(tmpEValidity.Text); oOffersBL.UpdateOffer(oOffers); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "<script> alert('Record Updated Successfully.')</script>", false); pnlAdd.Visible = true; //Rebind the latest data gvOfferDetails.EditIndex = -1; BindOfferGrid(); } }
protected void gvOfferDetails_RowDeleting(object sender, GridViewDeleteEventArgs e) { Offers oOffers = new Offers(); OffersBLogic oOfferBL = new OffersBLogic(); Label tmpofferId = (Label)gvOfferDetails.Rows[e.RowIndex].FindControl("lbloffferID"); if (tmpofferId != null) { oOffers.OfferID = tmpofferId.Text; } oOfferBL.DeleteOffer(oOffers); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "<script> alert('Record successfully deleted.')</script>", false); //Rebind the latest data BindOfferGrid(); }
protected void btnSave_Click(object sender, EventArgs e) { Offers oOffers = new Offers(); oOffers.OfferID = null; oOffers.OfferText = txtOfferText.Text; oOffers.OfferLink = txtOfferLink.Text; oOffers.Validity = int.Parse(txtValidity.Text); OffersBLogic oOffersBL = new OffersBLogic(); oOffersBL.InsertOffer(oOffers); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Message", "<script> alert('Record successfully inserted.')</script>", false); ClearFields(); //Rebind the latest data BindOfferGrid(); }