cacklebunny
asked on
concatenate two strings to make a textbox variable?
I'm drawing a blank on this one.
I have more than 100 textboxes. They each have id's such as "textbox1, textbox2, textbox3, textbox4," etc.
I want to loop through results of a SQL query, dynamically assigning the values for each of these textboxes:
for (int j=0;j<121;j++)
{
strTxtBoxTmp = "txtBox" + (j+1);
(strTxtBoxTmp).Text = astrMySymbols[j].ToString( );
}
This won't work. Is there a way to do this without manually writing out all the 100+ lines of textbox values? Seems like I could just easily do this with a FOR loop.
Thanks
I have more than 100 textboxes. They each have id's such as "textbox1, textbox2, textbox3, textbox4," etc.
I want to loop through results of a SQL query, dynamically assigning the values for each of these textboxes:
for (int j=0;j<121;j++)
{
strTxtBoxTmp = "txtBox" + (j+1);
(strTxtBoxTmp).Text = astrMySymbols[j].ToString(
}
This won't work. Is there a way to do this without manually writing out all the 100+ lines of textbox values? Seems like I could just easily do this with a FOR loop.
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm not exactly sure what you need, but here's a further example:
On my ASPX page, I have something like the following:
<asp:textbox maxlength="4" width="60" height="30" runat="server" style="font-size:20px;font -weight:bo ld" id="txtBox1" />
<asp:textbox maxlength="4" width="60" height="30" runat="server" style="font-size:20px;font -weight:bo ld" id="txtBox2" />
Now just imagine the above repeated more than a hundred times.
In my script, I have what is already noted above.
Thanks.
On my ASPX page, I have something like the following:
<asp:textbox maxlength="4" width="60" height="30" runat="server" style="font-size:20px;font
<asp:textbox maxlength="4" width="60" height="30" runat="server" style="font-size:20px;font
Now just imagine the above repeated more than a hundred times.
In my script, I have what is already noted above.
Thanks.
ASKER
Hi Carl:
That doesn't seem to work. I get the following error:
'System.Web.UI.ControlColl ection' does not contain a definition for 'Find'
That doesn't seem to work. I get the following error:
'System.Web.UI.ControlColl
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I only used three textboxes so please change the loop values.
:)
:)
ASKER
Bingo! Thanks, Babycorn.
Send Full Function
and might be declarion of your Textbox is problem
Thanks