How do i adress a dynamic generated textboxHow do I calculate someone's age in C#?Create Generic method constraining T to an EnumHow do I enumerate an enum in C#?How do I format a Microsoft JSON date?How do I use reflection to call a generic method?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How do I generate a random int number?How do servlets work? Instantiation, sessions, shared variables and multithreadingWhat is a NullReferenceException, and how do I fix it?How do i acces the value of a textbox I generated in a dynamic table

High income, sudden windfall

How do campaign rallies gain candidates votes?

Trapped in an ocean Temple in Minecraft?

Convert every file from JPEG to GIF in terminal

Why isn't there a serious attempt at creating a third mass-appeal party in the US?

Character is called by their first initial. How do I write it?

How to Create an Image for Cantor's *Diagonal Argument* with a Diagonal Oval

Why/when is AC-DC-AC conversion superior to direct AC-Ac conversion?

Get delta of days by current hour and added delta of days

Piece-drop Mate #2

Why can't my huge trees be chopped down?

How to start an application when a specific disk is mounted

Will any serial mouse connect to Classic Macs?

How to deal with a player who makes bad characters and kills them?

How do we explain the E major chord in this progression?

Why was Sauron preparing for war instead of trying to find the ring?

TSA asking to see cell phone

Why is drive/partition number still used?

Is my employer paying me fairly? Going from 1099 to W2

The Sword in the Stone

3D Statue Park: U shapes

Spoken encryption

Is dd if=/dev/urandom of=/dev/mem safe?

what happens if i forgot to feed my sourdough starter?



How do i adress a dynamic generated textbox


How do I calculate someone's age in C#?Create Generic method constraining T to an EnumHow do I enumerate an enum in C#?How do I format a Microsoft JSON date?How do I use reflection to call a generic method?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How do I generate a random int number?How do servlets work? Instantiation, sessions, shared variables and multithreadingWhat is a NullReferenceException, and how do I fix it?How do i acces the value of a textbox I generated in a dynamic table






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am creating a webshop and I am currently working on the shopping cart.I keep the products that the buyer wants in the shopping cart in sessions,and a table is generated on the "ShoppingCart" page.or each product in the shopping cart a row is created with a delete button, a text box for the number, and so on.I made a button "update cart" and when I press it I want the variable "number" of each product to be replaced there the number in the row of that product.but I don't know how to address the textboxes because, for example, "textbox1.text" doesn't work.



I do not know how many text boxes are going to be in advance .. that depends on how many different products the customer add's to his shopping cart.



some help would be greatly appreciated ! Thanks in advance !



This is the code where i generate the textboxes



private void vulCart()

myTable.Rows.Clear();

//header row aan maken
TableRow rowH = new TableRow();
TableCell cellH1 = new TableCell();
TableCell cellH2 = new TableCell();
TableCell cellH3 = new TableCell();
TableCell cellH4 = new TableCell();
TableCell cellH5 = new TableCell();
TableCell cellH6 = new TableCell();

cellH1.Text = "Id";
cellH1.CssClass = "bold";

cellH2.Text = "Product";
cellH2.CssClass = "bold";

cellH3.Text = "Prijs";
cellH3.CssClass = "bold";

cellH4.Text = "Aantal";
cellH4.CssClass = "bold";

cellH5.Text = "Totaal";
cellH5.CssClass = "bold";

cellH6.Text = "";
cellH6.CssClass = "bold";

rowH.Cells.Add(cellH1);
rowH.Cells.Add(cellH2);
rowH.Cells.Add(cellH3);
rowH.Cells.Add(cellH4);
rowH.Cells.Add(cellH5);
rowH.Cells.Add(cellH6);

myTable.Rows.Add(rowH);

//generate a row for each items in session "shoppingcart"
if (Session["ShoppingCart"] != null)

ShoppingCart cart = (ShoppingCart)Session["ShoppingCart"];

double totaal = 0;

// for elk product dat in shopping staat
for (int i = 0; i < cart.Items.Count; i++)

double totaalProduct = 0;

totaalProduct = Convert.ToDouble(cart.Items[i].Aantal) * Convert.ToDouble(cart.Items[i].Prijs);

TableRow row = new TableRow();

TableCell cell1 = new TableCell();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
TableCell cell4 = new TableCell();
TableCell cell5 = new TableCell();
TableCell cell6 = new TableCell();

Button btn_Delete = new Button();
btn_Delete.CssClass = "btn";
btn_Delete.Text = "Verwijder";
btn_Delete.Attributes.Add("ProductNaam", cart.Items[i].Product.ToString());
btn_Delete.Click += new EventHandler(Btn_Click);

cell1.Text = Convert.ToString(i + 1);
cell2.Text = cart.Items[i].Product.ToString();
cell3.Text = cart.Items[i].Prijs.ToString();
cell4.Text = cart.Items[i].Aantal.ToString();
cell5.Text = totaalProduct.ToString();
cell6.Controls.Add(btn_Delete);




row.Cells.Add(cell1);
row.Cells.Add(cell2);
row.Cells.Add(cell3);
row.Cells.Add(cell4);
row.Cells.Add(cell5);
row.Cells.Add(cell6);

myTable.Rows.Add(row);

totaal = totaal + totaalProduct;















share|improve this question






















  • Use FindControl myTable.Rows[1].Cells[1].FindControl("TextBox1") as TextBox. Make sure to give the dynamic controls an ID.

    – VDWWD
    Mar 26 at 22:08











  • Is the "TextBox1" the id ?

    – Anthony Decap
    Mar 27 at 15:14











  • Yes, but you have to assign it yourself when using dynamic controls.

    – VDWWD
    Mar 27 at 15:16

















0















I am creating a webshop and I am currently working on the shopping cart.I keep the products that the buyer wants in the shopping cart in sessions,and a table is generated on the "ShoppingCart" page.or each product in the shopping cart a row is created with a delete button, a text box for the number, and so on.I made a button "update cart" and when I press it I want the variable "number" of each product to be replaced there the number in the row of that product.but I don't know how to address the textboxes because, for example, "textbox1.text" doesn't work.



I do not know how many text boxes are going to be in advance .. that depends on how many different products the customer add's to his shopping cart.



some help would be greatly appreciated ! Thanks in advance !



This is the code where i generate the textboxes



private void vulCart()

myTable.Rows.Clear();

//header row aan maken
TableRow rowH = new TableRow();
TableCell cellH1 = new TableCell();
TableCell cellH2 = new TableCell();
TableCell cellH3 = new TableCell();
TableCell cellH4 = new TableCell();
TableCell cellH5 = new TableCell();
TableCell cellH6 = new TableCell();

cellH1.Text = "Id";
cellH1.CssClass = "bold";

cellH2.Text = "Product";
cellH2.CssClass = "bold";

cellH3.Text = "Prijs";
cellH3.CssClass = "bold";

cellH4.Text = "Aantal";
cellH4.CssClass = "bold";

cellH5.Text = "Totaal";
cellH5.CssClass = "bold";

cellH6.Text = "";
cellH6.CssClass = "bold";

rowH.Cells.Add(cellH1);
rowH.Cells.Add(cellH2);
rowH.Cells.Add(cellH3);
rowH.Cells.Add(cellH4);
rowH.Cells.Add(cellH5);
rowH.Cells.Add(cellH6);

myTable.Rows.Add(rowH);

//generate a row for each items in session "shoppingcart"
if (Session["ShoppingCart"] != null)

ShoppingCart cart = (ShoppingCart)Session["ShoppingCart"];

double totaal = 0;

// for elk product dat in shopping staat
for (int i = 0; i < cart.Items.Count; i++)

double totaalProduct = 0;

totaalProduct = Convert.ToDouble(cart.Items[i].Aantal) * Convert.ToDouble(cart.Items[i].Prijs);

TableRow row = new TableRow();

TableCell cell1 = new TableCell();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
TableCell cell4 = new TableCell();
TableCell cell5 = new TableCell();
TableCell cell6 = new TableCell();

Button btn_Delete = new Button();
btn_Delete.CssClass = "btn";
btn_Delete.Text = "Verwijder";
btn_Delete.Attributes.Add("ProductNaam", cart.Items[i].Product.ToString());
btn_Delete.Click += new EventHandler(Btn_Click);

cell1.Text = Convert.ToString(i + 1);
cell2.Text = cart.Items[i].Product.ToString();
cell3.Text = cart.Items[i].Prijs.ToString();
cell4.Text = cart.Items[i].Aantal.ToString();
cell5.Text = totaalProduct.ToString();
cell6.Controls.Add(btn_Delete);




row.Cells.Add(cell1);
row.Cells.Add(cell2);
row.Cells.Add(cell3);
row.Cells.Add(cell4);
row.Cells.Add(cell5);
row.Cells.Add(cell6);

myTable.Rows.Add(row);

totaal = totaal + totaalProduct;















share|improve this question






















  • Use FindControl myTable.Rows[1].Cells[1].FindControl("TextBox1") as TextBox. Make sure to give the dynamic controls an ID.

    – VDWWD
    Mar 26 at 22:08











  • Is the "TextBox1" the id ?

    – Anthony Decap
    Mar 27 at 15:14











  • Yes, but you have to assign it yourself when using dynamic controls.

    – VDWWD
    Mar 27 at 15:16













0












0








0








I am creating a webshop and I am currently working on the shopping cart.I keep the products that the buyer wants in the shopping cart in sessions,and a table is generated on the "ShoppingCart" page.or each product in the shopping cart a row is created with a delete button, a text box for the number, and so on.I made a button "update cart" and when I press it I want the variable "number" of each product to be replaced there the number in the row of that product.but I don't know how to address the textboxes because, for example, "textbox1.text" doesn't work.



I do not know how many text boxes are going to be in advance .. that depends on how many different products the customer add's to his shopping cart.



some help would be greatly appreciated ! Thanks in advance !



This is the code where i generate the textboxes



private void vulCart()

myTable.Rows.Clear();

//header row aan maken
TableRow rowH = new TableRow();
TableCell cellH1 = new TableCell();
TableCell cellH2 = new TableCell();
TableCell cellH3 = new TableCell();
TableCell cellH4 = new TableCell();
TableCell cellH5 = new TableCell();
TableCell cellH6 = new TableCell();

cellH1.Text = "Id";
cellH1.CssClass = "bold";

cellH2.Text = "Product";
cellH2.CssClass = "bold";

cellH3.Text = "Prijs";
cellH3.CssClass = "bold";

cellH4.Text = "Aantal";
cellH4.CssClass = "bold";

cellH5.Text = "Totaal";
cellH5.CssClass = "bold";

cellH6.Text = "";
cellH6.CssClass = "bold";

rowH.Cells.Add(cellH1);
rowH.Cells.Add(cellH2);
rowH.Cells.Add(cellH3);
rowH.Cells.Add(cellH4);
rowH.Cells.Add(cellH5);
rowH.Cells.Add(cellH6);

myTable.Rows.Add(rowH);

//generate a row for each items in session "shoppingcart"
if (Session["ShoppingCart"] != null)

ShoppingCart cart = (ShoppingCart)Session["ShoppingCart"];

double totaal = 0;

// for elk product dat in shopping staat
for (int i = 0; i < cart.Items.Count; i++)

double totaalProduct = 0;

totaalProduct = Convert.ToDouble(cart.Items[i].Aantal) * Convert.ToDouble(cart.Items[i].Prijs);

TableRow row = new TableRow();

TableCell cell1 = new TableCell();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
TableCell cell4 = new TableCell();
TableCell cell5 = new TableCell();
TableCell cell6 = new TableCell();

Button btn_Delete = new Button();
btn_Delete.CssClass = "btn";
btn_Delete.Text = "Verwijder";
btn_Delete.Attributes.Add("ProductNaam", cart.Items[i].Product.ToString());
btn_Delete.Click += new EventHandler(Btn_Click);

cell1.Text = Convert.ToString(i + 1);
cell2.Text = cart.Items[i].Product.ToString();
cell3.Text = cart.Items[i].Prijs.ToString();
cell4.Text = cart.Items[i].Aantal.ToString();
cell5.Text = totaalProduct.ToString();
cell6.Controls.Add(btn_Delete);




row.Cells.Add(cell1);
row.Cells.Add(cell2);
row.Cells.Add(cell3);
row.Cells.Add(cell4);
row.Cells.Add(cell5);
row.Cells.Add(cell6);

myTable.Rows.Add(row);

totaal = totaal + totaalProduct;















share|improve this question














I am creating a webshop and I am currently working on the shopping cart.I keep the products that the buyer wants in the shopping cart in sessions,and a table is generated on the "ShoppingCart" page.or each product in the shopping cart a row is created with a delete button, a text box for the number, and so on.I made a button "update cart" and when I press it I want the variable "number" of each product to be replaced there the number in the row of that product.but I don't know how to address the textboxes because, for example, "textbox1.text" doesn't work.



I do not know how many text boxes are going to be in advance .. that depends on how many different products the customer add's to his shopping cart.



some help would be greatly appreciated ! Thanks in advance !



This is the code where i generate the textboxes



private void vulCart()

myTable.Rows.Clear();

//header row aan maken
TableRow rowH = new TableRow();
TableCell cellH1 = new TableCell();
TableCell cellH2 = new TableCell();
TableCell cellH3 = new TableCell();
TableCell cellH4 = new TableCell();
TableCell cellH5 = new TableCell();
TableCell cellH6 = new TableCell();

cellH1.Text = "Id";
cellH1.CssClass = "bold";

cellH2.Text = "Product";
cellH2.CssClass = "bold";

cellH3.Text = "Prijs";
cellH3.CssClass = "bold";

cellH4.Text = "Aantal";
cellH4.CssClass = "bold";

cellH5.Text = "Totaal";
cellH5.CssClass = "bold";

cellH6.Text = "";
cellH6.CssClass = "bold";

rowH.Cells.Add(cellH1);
rowH.Cells.Add(cellH2);
rowH.Cells.Add(cellH3);
rowH.Cells.Add(cellH4);
rowH.Cells.Add(cellH5);
rowH.Cells.Add(cellH6);

myTable.Rows.Add(rowH);

//generate a row for each items in session "shoppingcart"
if (Session["ShoppingCart"] != null)

ShoppingCart cart = (ShoppingCart)Session["ShoppingCart"];

double totaal = 0;

// for elk product dat in shopping staat
for (int i = 0; i < cart.Items.Count; i++)

double totaalProduct = 0;

totaalProduct = Convert.ToDouble(cart.Items[i].Aantal) * Convert.ToDouble(cart.Items[i].Prijs);

TableRow row = new TableRow();

TableCell cell1 = new TableCell();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
TableCell cell4 = new TableCell();
TableCell cell5 = new TableCell();
TableCell cell6 = new TableCell();

Button btn_Delete = new Button();
btn_Delete.CssClass = "btn";
btn_Delete.Text = "Verwijder";
btn_Delete.Attributes.Add("ProductNaam", cart.Items[i].Product.ToString());
btn_Delete.Click += new EventHandler(Btn_Click);

cell1.Text = Convert.ToString(i + 1);
cell2.Text = cart.Items[i].Product.ToString();
cell3.Text = cart.Items[i].Prijs.ToString();
cell4.Text = cart.Items[i].Aantal.ToString();
cell5.Text = totaalProduct.ToString();
cell6.Controls.Add(btn_Delete);




row.Cells.Add(cell1);
row.Cells.Add(cell2);
row.Cells.Add(cell3);
row.Cells.Add(cell4);
row.Cells.Add(cell5);
row.Cells.Add(cell6);

myTable.Rows.Add(row);

totaal = totaal + totaalProduct;












c# asp.net session session-variables session-state






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 17:40









Anthony DecapAnthony Decap

32 bronze badges




32 bronze badges












  • Use FindControl myTable.Rows[1].Cells[1].FindControl("TextBox1") as TextBox. Make sure to give the dynamic controls an ID.

    – VDWWD
    Mar 26 at 22:08











  • Is the "TextBox1" the id ?

    – Anthony Decap
    Mar 27 at 15:14











  • Yes, but you have to assign it yourself when using dynamic controls.

    – VDWWD
    Mar 27 at 15:16

















  • Use FindControl myTable.Rows[1].Cells[1].FindControl("TextBox1") as TextBox. Make sure to give the dynamic controls an ID.

    – VDWWD
    Mar 26 at 22:08











  • Is the "TextBox1" the id ?

    – Anthony Decap
    Mar 27 at 15:14











  • Yes, but you have to assign it yourself when using dynamic controls.

    – VDWWD
    Mar 27 at 15:16
















Use FindControl myTable.Rows[1].Cells[1].FindControl("TextBox1") as TextBox. Make sure to give the dynamic controls an ID.

– VDWWD
Mar 26 at 22:08





Use FindControl myTable.Rows[1].Cells[1].FindControl("TextBox1") as TextBox. Make sure to give the dynamic controls an ID.

– VDWWD
Mar 26 at 22:08













Is the "TextBox1" the id ?

– Anthony Decap
Mar 27 at 15:14





Is the "TextBox1" the id ?

– Anthony Decap
Mar 27 at 15:14













Yes, but you have to assign it yourself when using dynamic controls.

– VDWWD
Mar 27 at 15:16





Yes, but you have to assign it yourself when using dynamic controls.

– VDWWD
Mar 27 at 15:16












0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55363254%2fhow-do-i-adress-a-dynamic-generated-textbox%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55363254%2fhow-do-i-adress-a-dynamic-generated-textbox%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript