Retaining values of TextBox control I've programmatically created in C#

killer007

New Member
I've been struggling this for a couple of hours now and can't seem to find the answer online. Several practices I've found online haven't done the job so I guess I'm doing something wrong.I created a Table object, placed several TableRow objects under which I've placed TableCell. One column of this table consists of TextBox objects I've created:\[code\]Table productTable = new Table();int j = 0;foreach (Product i in prodList) { TextBox qttyTB = new TextBox(); qttyTB.ID = "Quantity" + Convert.ToString(j); qttyTB.Style["width"] = "30px"; qttyTB.Text = "0"; TableRow tableR = new TableRow(); TableCell tableC1 = new TableCell(); tableC1.Text = "<img src='" + i.ImagePath + "' class='ProductImage'/>"; tableR.Controls.Add(tableC1); TableCell tableC2 = new TableCell(); tableC2.Text = i.Name + "&nbsp;&nbsp;&nbsp;&nbsp;"; tableR.Controls.Add(tableC2); TableCell tableC3 = new TableCell(); tableC3.Text = i.Price + "&nbsp;₪&nbsp;&nbsp;&nbsp;&nbsp;"; tableR.Controls.Add(tableC3); TableCell tableC4 = new TableCell(); tableC4.Controls.Add(tbArray[j - 1]); tableR.Controls.Add(tableC4); productTable.Controls.Add(tableR); j++; }TablePH.Controls.Add(productTable);\[/code\]The page output works 100%. Now, upon a button click I'm trying to retain the values of the TextBox objects I've created. Tried several things.Any assistance is greatly appreciated!Yuval.
 
Back
Top