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

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -