ISPostback solves the problem of server-side issues that cannot transmit ASP: Text

xiaoxiao2021-03-06  22

using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls Using system.web.ui.htmlcontrols; using wztj.page.product.Model; using wztj.page.product.code; using wztj.page.category.code; using system.text;

namespace wztj.page.rfq {///

/// Summary description for UpdateProduct /// public class UpdateProduct:. System.Web.UI.Page {protected System.Web.UI.WebControls.TextBox name; protected System.Web.UI.WebControls.TextBox manufacture; protected System.Web.UI.WebControls.TextBox quantity; protected System.Web.UI.WebControls.TextBox unit; protected System.Web.UI.WebControls.TextBox classType; protected System.Web.UI.WebControls.TextBox status; protected System.Web.UI.WebControls.TextBox description; protected System.Web.UI.WebControls.TextBox quotedPrice; protected System.Web.UI.WebControls.DropDownList DropDownList1; protected System .Web.UI.WebControls.Button Button1; protected System.Web.UI.WebControls.Label Label1; protected System.Web.UI.HtmlControls.HtmlForm Form1; protected System.Web.UI.HtmlControls.HtmlInputText expirationDate; protected string ProductID; Protected Product Product; Protected String UserName; Protected String ProductTyPe; Priv ate void Page_Load (object sender, System.EventArgs e) {ProductID = this.Request.QueryString.Get ( "ProductID");. username = Session [ "username"] ToString (); ProductManager productManager = new ProductManager (); product = productManager.getProductByProductID (ProductID); if (! this.IsPostBack) {this.name.Text = product.Name; this.manufacture.Text = product.Manufacture; this.quantity.Text = product.Quantity.ToString (); this.unit.Text = product.Unit; this.classType.Text = product.ClassType; this.status.Text = product.Status; this.description.Text = product.Description; this.quotedPrice.Text = product.QuotedPrice. Tostring ();

this.expirationDate.Value = product.ExpirationDate; CategoryManager categoryManager = new CategoryManager (); DataTable dt = categoryManager.getRootCategories (); this.DropDownList1.DataSource = dt; this.DropDownList1.DataTextField = "categoryName"; this.DropDownList1.DataBind ();} this.productType = product.ProductType; // Put user code to initialize the page here} #region Web Form Designer generated code override protected void OnInit (EventArgs e) {// // CODEGEN: This call is required by THE ASP.NET Web Formomponent (); Base.onit (E);} ///

/// Required method for designer support - do not modify /// The contents of this method with the content code editor /// private void InitializeComponent () {this.Button1.Click = new System.EventHandler (this.Button1_Click);. this.Load = new System.EventHandler (this.Page_Load);

} #Endregion

private void Button1_Click (object sender, System.EventArgs e) {ProductManager productManager = new ProductManager (); Product product = productManager.getProduct (username, this.name.Text, this.manufacture.Text, Double.Parse (this.quantity. Text), this.Unit.text, this.classtype.text, this.status.text, this.description.text, double.Pars (this.quotedprice.text), this.ExpirationDate.Value, this.dropdownList1.selectedItem. TEXT, PRODUCTTYPE; Product.Id = long.parse (ProductID); ProductManager.UpdateProduct (Product);}}}

转载请注明原文地址:https://www.9cbs.com/read-65136.html

New Post(0)