private void Update() { HardwareClasses.clsStockCollection AddressBook = new HardwareClasses.clsStockCollection(); String Error = AddressBook.ThisStock.Valid(txtPrice.Text, txtPartDescription.Text, txtQuantity.Text, txtDate.Text); //if the data is OK then add it to the object if (Error == "") { //find the record to update AddressBook.ThisStock.Find(PartNo); //get the data entered by the user AddressBook.ThisStock.PartDescription = txtPartDescription.Text; AddressBook.ThisStock.Price = Convert.ToInt32(txtPrice.Text); AddressBook.ThisStock.Quantity = Convert.ToInt32(txtQuantity.Text); AddressBook.ThisStock.DateAdded = Convert.ToDateTime(txtDate.Text); AddressBook.ThisStock.Available = ChkAvailable.Checked; //update the record AddressBook.Update(); //all done so redirect back to the main page Response.Redirect("DefaultStock.aspx"); } else { //report an error lblError.Text = "There were problems with the data entered " + Error; } }
void DisplayStock() { HardwareClasses.clsStockCollection stock = new HardwareClasses.clsStockCollection(); lstStockList.DataSource = stock.StockList; lstStockList.DataValueField = "PartNo"; lstStockList.DataTextField = "PostCode"; lstStockList.DataBind(); }