473,378 Members | 1,175 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,378 software developers and data experts.

get content of text boxes dynamically created

Hi all,

I create a set of text-boxes based on user input:

for (int i = 0; i < Convert.ToInt16(keywordsDropDownList.Text);
i++)
{
myTextBox = new TextBox();
myTextBox.Columns = 5;
myTextBox.ID = "parameterTextBox"+Convert.ToInt16(i);
myTextBox.TabIndex = (short) (i+1);
buttonPlaceHolder.Controls.Add(myTextBox);
}

The text boxes are followed by a button that, when clicked, should get
the content form the text boxes and put em in a database. How can I get
the content from teh text boxes?

I cannot use
someVar = parameterTextBox0.text
since it is not known

Thanks in advance
Stijn

Aug 31 '06 #1
5 1589
Stijn,

buttonPlaceHolder.FindControl ("parameterTextBox1") as TextBox

should do.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
<ta******@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hi all,

I create a set of text-boxes based on user input:

for (int i = 0; i < Convert.ToInt16(keywordsDropDownList.Text);
i++)
{
myTextBox = new TextBox();
myTextBox.Columns = 5;
myTextBox.ID = "parameterTextBox"+Convert.ToInt16(i);
myTextBox.TabIndex = (short) (i+1);
buttonPlaceHolder.Controls.Add(myTextBox);
}

The text boxes are followed by a button that, when clicked, should get
the content form the text boxes and put em in a database. How can I get
the content from teh text boxes?

I cannot use
someVar = parameterTextBox0.text
since it is not known

Thanks in advance
Stijn

Aug 31 '06 #2
But you can use Page.FindControl

TextBox tb = (TextBox)Page.FindControl("parameterTextBox0");
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

<ta******@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hi all,

I create a set of text-boxes based on user input:

for (int i = 0; i < Convert.ToInt16(keywordsDropDownList.Text);
i++)
{
myTextBox = new TextBox();
myTextBox.Columns = 5;
myTextBox.ID = "parameterTextBox"+Convert.ToInt16(i);
myTextBox.TabIndex = (short) (i+1);
buttonPlaceHolder.Controls.Add(myTextBox);
}

The text boxes are followed by a button that, when clicked, should get
the content form the text boxes and put em in a database. How can I get
the content from teh text boxes?

I cannot use
someVar = parameterTextBox0.text
since it is not known

Thanks in advance
Stijn

Aug 31 '06 #3
Thanks for the reply. i haven't made it work yet though. It seems that
FindControl can't find the textbox since null is returned. The
textboxes are placed inside a view (and multiview) and then inside a
placeholder (suing a masterpage). Maybe this is the reason why null is
returned?

Regards,
Stijn

Teemu Keiski schreef:
But you can use Page.FindControl

TextBox tb = (TextBox)Page.FindControl("parameterTextBox0");
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

<ta******@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hi all,

I create a set of text-boxes based on user input:

for (int i = 0; i < Convert.ToInt16(keywordsDropDownList.Text);
i++)
{
myTextBox = new TextBox();
myTextBox.Columns = 5;
myTextBox.ID = "parameterTextBox"+Convert.ToInt16(i);
myTextBox.TabIndex = (short) (i+1);
buttonPlaceHolder.Controls.Add(myTextBox);
}

The text boxes are followed by a button that, when clicked, should get
the content form the text boxes and put em in a database. How can I get
the content from teh text boxes?

I cannot use
someVar = parameterTextBox0.text
since it is not known

Thanks in advance
Stijn
Sep 1 '06 #4
Hi all,

I tried the findcontrol with textbox I added via the editor but that
also returned a null. I used Page.findcontrol(id) and just
findcontrol(id).

Someone has an idea what I'm doing wrong?

Regards
Stijn
ta******@gmail.com schreef:
Thanks for the reply. i haven't made it work yet though. It seems that
FindControl can't find the textbox since null is returned. The
textboxes are placed inside a view (and multiview) and then inside a
placeholder (suing a masterpage). Maybe this is the reason why null is
returned?

Regards,
Stijn

Teemu Keiski schreef:
But you can use Page.FindControl

TextBox tb = (TextBox)Page.FindControl("parameterTextBox0");
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

<ta******@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hi all,
>
I create a set of text-boxes based on user input:
>
for (int i = 0; i < Convert.ToInt16(keywordsDropDownList.Text);
i++)
{
myTextBox = new TextBox();
myTextBox.Columns = 5;
myTextBox.ID = "parameterTextBox"+Convert.ToInt16(i);
myTextBox.TabIndex = (short) (i+1);
buttonPlaceHolder.Controls.Add(myTextBox);
}
>
The text boxes are followed by a button that, when clicked, should get
the content form the text boxes and put em in a database. How can I get
the content from teh text boxes?
>
I cannot use
someVar = parameterTextBox0.text
since it is not known
>
Thanks in advance
Stijn
>
Sep 1 '06 #5
You need to call FindControl on the control that directly contains the
control you are trying to find. Did you try my suggestion

buttonPlaceHolder.FindControl ("parameterTextBox1") as TextBox ?

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
<ta******@gmail.comwrote in message
news:11**********************@74g2000cwt.googlegro ups.com...
Hi all,

I tried the findcontrol with textbox I added via the editor but that
also returned a null. I used Page.findcontrol(id) and just
findcontrol(id).

Someone has an idea what I'm doing wrong?

Regards
Stijn
ta******@gmail.com schreef:
>Thanks for the reply. i haven't made it work yet though. It seems that
FindControl can't find the textbox since null is returned. The
textboxes are placed inside a view (and multiview) and then inside a
placeholder (suing a masterpage). Maybe this is the reason why null is
returned?

Regards,
Stijn

Teemu Keiski schreef:
But you can use Page.FindControl

TextBox tb = (TextBox)Page.FindControl("parameterTextBox0");
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

<ta******@gmail.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
Hi all,

I create a set of text-boxes based on user input:

for (int i = 0; i < Convert.ToInt16(keywordsDropDownList.Text);
i++)
{
myTextBox = new TextBox();
myTextBox.Columns = 5;
myTextBox.ID = "parameterTextBox"+Convert.ToInt16(i);
myTextBox.TabIndex = (short) (i+1);
buttonPlaceHolder.Controls.Add(myTextBox);
}

The text boxes are followed by a button that, when clicked, should
get
the content form the text boxes and put em in a database. How can I
get
the content from teh text boxes?

I cannot use
someVar = parameterTextBox0.text
since it is not known

Thanks in advance
Stijn

Sep 3 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dale | last post by:
I am trying to figure out how to have a script dynamically create and then dispose of a text file. A script will generate a text file using the standard I/O functions and then present a link so...
11
by: Robert Bowen | last post by:
Hello all. I have been given mock-ups (in static HTML) of some pages for a site I am working on. The client would like these pages to look exactly as they do now. The problem is that the content is...
1
by: sekisho | last post by:
I'm dynamically adding a column of labels and a column of text boxes to a panel on a webform, based on data returned from an SQL query, which the user builds by selecting options from a few...
3
by: simon | last post by:
Hello, i'm looking to create an aspx page that is basically a FAQ page i'm not sure if this can be done, but would love some help with suggestions of how to do it another way if this is not...
2
by: Sethos | last post by:
I am sure that this has been covered, hashed, and rehashed, but a search on the group did not produce the answer, so forgive me if this seems like a "newbie" type question... Besically, I have a...
0
by: nick78 | last post by:
hi, i want to create a web form where someone can do some input or pick strings from select boxes. after that the person can click a preview button and a website will be generated dynamically....
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: adarshyam | last post by:
can anybody tel me how to clear values from dynamically created text boxes?? using a clear button.. this is the code used to create dynamic text boxes.. if i press clear button then it must clear all...
5
by: ofilha | last post by:
I have created a report in design mode. However, some of the fields i need are dynamic. That is, i have a series of fields text boxes mostly that must show up only as needed. I also have some...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.