Wrox Programmer Forums
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 15th, 2004, 02:55 AM
Registered User
 
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default textbox C#

I am working on eshop project, Once i click a specific product item, it will add it to the cart, and there the user have the right to change the quantity.
As you know i am doing a while loop to show all items added to my cart, but i am not able to get the new quantity updated by the user:
while (objDataReader.Read()== true)
{
szPID = objDataReader.GetString("PID");
intQUANTITY = objDataReader.GetInt32("QUANTITY");
TextBox AddQtytxt = new TextBox();
AddQtytxt.Text = intQUANTITY.ToString();
AddQtytxt.Attributes["onchange"] = "AddQtytxt_TextChanged('" +szPID+ "','"
+AddQtytxt.Text+ "');";
}

i KNOW THAT THE PROBLEM IS if i use AddQtytxt.AutoPostBack = true; it is recreating the textbox from scratch, but can you let me know a way to do what i need,
Thx in advance for ur support,


using Visual Studio .net (C#)
 
Old September 15th, 2004, 07:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Consider storing the value of the quantity an the viewstate. Also, the code above, is that in the page_load event? Could you post the entire method?

Thanks,

Brian
 
Old September 15th, 2004, 09:01 AM
Registered User
 
Join Date: Sep 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

//no the code is not in page load,
//i create a page called page.aspx, inside i placed a placeholder phShoppingCart
// before listing the items i use a method to add items to database

protected Classes.ShoppingCart objShoppingCart = new Classes.ShoppingCart();
phShoppingCart.Controls.Add(objShoppingCart.Listin gCartItem(szSCI));
// where szSCI is the id of the cart


in Classes --> ShoppingCart i add this

public Table ListingCartItem(string cartID,int flag)
{

Table objTable=null;
TableRow objRow=null;
TableCell objCell=null;
// i connect to database
while (objDataReader.Read()== true)
{

// product id
szPID = objDataReader.GetString("PID");
intQUANTITY = objDataReader.GetInt32("QUANTITY");

// i open table and add PId and product name
TextBox AddQtytxt = new TextBox();
AddQtytxt.ReadOnly = false;
AddQtytxt.Text = intQUANTITY.ToString();
//AddQtytxt.Width = Unit.Pixel(80);
//AddQtytxt.AutoPostBack = true;
//AddQtytxt.Attributes["onchange"] = "AddQtytxt_TextChanged('" +szPID+ "','" +AddQtytxt.Text+ "');";
AddQtytxt.TextChanged += new System.EventHandler(this.AddQtytxt_TextChanged);
// Quantity Cell
objCell = new TableCell();
objCell.BorderWidth=Unit.Pixel(1);
objCell.HorizontalAlign=HorizontalAlign.Center;
objCell.Controls.Add(AddQtytxt);
objRow.Cells.Add(objCell);
// I close the table
}














Similar Threads
Thread Thread Starter Forum Replies Last Post
TextBox Help iceman90289 C# 2005 6 April 6th, 2008 03:54 AM
pointing cursor from one textbox to other textbox lakshmi_annayappa ASP.NET 1.0 and 1.1 Basics 2 August 2nd, 2007 03:41 PM
Textbox deontae45 VB.NET 2002/2003 Basics 1 September 25th, 2006 11:26 AM
Masked TextBox & formatting TextBox melvik C# 1 September 22nd, 2003 11:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.