473,320 Members | 2,122 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

dynamically adding textbox

Hi,
the below code is for dynamically adding textbox, but it will adding for same textbox only my requirement is how many times i click add button such times textbox will add
for ex: if i click 10 times add button 10 textboxs will add
Expand|Select|Wrap|Line Numbers
  1. Session["TextBoxCount"] = "3";
  2.  
  3.          for (int a = 0; a < int.Parse(Session["TextBoxCount"].ToString()); a++)
  4.          {
  5.              TableRow tr = new TableRow();
  6.              TableCell tc = new TableCell();
  7.              TextBox tb = new TextBox();
  8.  
  9.              tb.Attributes.Add("runat", "Server");
  10.              tb.EnableViewState = false;
  11.              tb.MaxLength = 128;
  12.              tb.ID = "TextBox" + a;
  13.  
  14.              tc.Controls.Add(tb);
  15.              tr.Cells.Add(tc);
  16.              ctrlTable.Rows.Add(tr);
Apr 22 '08 #1
2 1349
shweta123
692 Expert 512MB
Hi,

What error are you getting into this?



Hi,
the below code is for dynamically adding textbox, but it will adding for same textbox only my requirement is how many times i click add button such times textbox will add
for ex: if i click 10 times add button 10 textboxs will add
Session["TextBoxCount"] = "3";

for (int a = 0; a < int.Parse(Session["TextBoxCount"].ToString()); a++)
{
TableRow tr = new TableRow();
TableCell tc = new TableCell();
TextBox tb = new TextBox();

tb.Attributes.Add("runat", "Server");
tb.EnableViewState = false;
tb.MaxLength = 128;
tb.ID = "TextBox" + a;

tc.Controls.Add(tb);
tr.Cells.Add(tc);
ctrlTable.Rows.Add(tr);
Apr 22 '08 #2
Frinavale
9,735 Expert Mod 8TB
Are you getting any errors?
Have you seen this article on how to use dynamic controls in ASP.NET? It has an example on how to dynamically add Textboxes to your web pages.

-Frinny
Apr 22 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: LU | last post by:
I have code to dynamically add more text boxes when the user clicks the 'add another carrier' button. Problem is it creates the text boxes within the same table row as previously created boxes. ...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
4
by: Bas Groeneveld | last post by:
I am developing an ASP.NET application part of which consists of a data entry wizard defined by entries in a data table - ie the controls on each page of the wizard are determined by definitions in...
2
by: Quentin Huo | last post by:
Hi: I have a user control and I want to dynamically create a Label control and TextBox control when the button "add more author name" is clicked. I did like this: 1. there is a...
2
by: buran | last post by:
Dear ASP.NET Programmers, I have a HTML table (running as server control with the control ID: tblInsertSP). The table has 16 rows with textboxes. Depending on the value of the ddlSPType, which...
2
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
0
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event,...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
1
by: mazdotnet | last post by:
Hi all, I have Repeater dynamically adding textboxes to a placeholder and connecting it to AjaxControlToolkit.PopupControlExtender which works fine. I'm adding the textboxes using the following...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.