private void GvShipper_RowDeleting(object sender, GridViewDeleteEventArgs e) { if (Session["shippers"] != null) { ShipperList shippers = (ShipperList)Session["shippers"]; Shipper shipper = shippers.List[e.RowIndex]; shipper.Deleted = true; shipper.Save(); } gvShipper.EditIndex = -1; getAll(); }
private void GvShipper_RowUpdating(object sender, GridViewUpdateEventArgs e) { TextBox txtCompanyName = (TextBox)gvShipper.Rows[e.RowIndex].FindControl("txtCompanyName"); TextBox txtPhone = (TextBox)gvShipper.Rows[e.RowIndex].FindControl("txtPhone"); FileUpload fu = (FileUpload)gvShipper.Rows[e.RowIndex].FindControl("fileupload1"); if (Session["shippers"] != null) { ShipperList shippers = (ShipperList)Session["shippers"]; Shipper shipper = shippers.List[e.RowIndex]; shipper.CompanyName = txtCompanyName.Text; shipper.Phone = txtPhone.Text; shipper.FullPathfileName = Path.Combine(Server.MapPath("Files"), fu.FileName); shipper.Image = fu.FileBytes; shipper.Save(); } gvShipper.EditIndex = -1; getAll(); }
private void getAll() { shippers.MapPath = Server.MapPath("Files"); shippers = shippers.GetAll(); if (Session["Shippers"] == null) { Session["Shippers"] = shippers; } Shipper shipper = new Shipper(); gvShipper.DataSource = shippers.List; shippers.List.Add(shipper); gvShipper.DataBind(); int row = gvShipper.Rows.Count - 1; ((LinkButton)gvShipper.Rows[row].Cells[0].Controls[1]).Text = "Add"; }