c# - Retrieve value from dynamic TextBox -
i have button
creates list of textboxes
dynamically , have button
submits information. don't know how access values of textboxes
. below code:
if (ispostback) { viewstate["count"] = convert.toint32(viewstate["count"]) + 1; int count = int.parse(string.format("{0}", viewstate["count"])); var lsttextbox = new list<textbox>(); (int = 0; < counter; i++) { textbox txtbx = new textbox(); txtbx.id = string.format("txtbx{0}", i); // txtbx.autopostback = true; lsttextbox.add(txtbx); //txtbx.text = "initial value"; } session["lsttextbox"] = lsttextbox; } protected void button1_click(object sender, eventargs e) { int total = counter; (int = 0; < total; i++)//calls createbox createtextbox(i); //label1.text = counter.tostring(); if (counter == 4) { button1.visible = false; } } private int counter { { return convert.toint32(viewstate["count"] ?? "0"); } //fields button counter set { viewstate["count"] = value; } } private void createtextbox(int j) //creates fields / cells { var box = new textbox(); box.id = "textbox" + j; box.text = "textbox" + j; var c = new tablecell(); c.controls.add(box); r.cells.add(c); table1.rows.add(r); }
how have button2
grab values.
thank in advance!!
do this
foreach(control c in yourcontrolholder.controls) { if(c textbox) { //your code here. } }
Comments
Post a Comment