473,397 Members | 2,099 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,397 software developers and data experts.

Dim a dynamic name

I want to create textboxes dynamically but with dynamic names also.

i am retrieveing a load of values from a table in SQL into a DataReader.
Then i want to create textboxes from those variables. I want to dim various
textboxes with different names depending on what I retrieve from SQL. I
tried the following:

dim dtrcondet.item("contact_detail_description") as new textbox()

but this does not work

Can anyone help?

----
Mark
Oct 31 '05 #1
7 1815
Is this a .net app? E.g. .ASPX? If so, this should really be posted in
microsoft.public.dotnet.framework.aspnet, or
microsoft.public.dotnet.languages.vb if it's a general thing - your post
isn't clear.

What you want to do isn't possible. However, a work around would be to have
a hashtable that you add the items to. When you make a new textbox, you set
the TAG property to the value of
dtrcondet.item("contact_detail_description"), then you can look in the
hashtable for the corresponding value. However, you might not even need the
hashtable, you could just use the TAG value.

Sorry if that's a bit unclear, but I can't figure out why you'd want dynamic
text boxes in that manner anyway, or what you're trying to do with them :)

Jevon
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
I want to create textboxes dynamically but with dynamic names also.

i am retrieveing a load of values from a table in SQL into a DataReader.
Then i want to create textboxes from those variables. I want to dim
various
textboxes with different names depending on what I retrieve from SQL. I
tried the following:

dim dtrcondet.item("contact_detail_description") as new textbox()

but this does not work

Can anyone help?

----
Mark

Oct 31 '05 #2
Mark wrote:
I want to create textboxes dynamically but with dynamic names also.

i am retrieveing a load of values from a table in SQL into a
DataReader.
There was no way for you to know it, but this is a classic asp newsgroup.
While you may be lucky enough to find a dotnet-knowledgeable person here who
can answer your question, you can eliminate the luck factor by posting your
question to a group where those dotnet-knowledgeable people hang out. I
suggest microsoft.public.dotnet.framework.aspnet.
Then i want to create textboxes from those variables. I
want to dim various textboxes with different names depending on what
I retrieve from SQL. I tried the following:

dim dtrcondet.item("contact_detail_description") as new textbox()

but this does not work

Can anyone help?


I don't think it's possible*, and even if it was, I don't think it's a good
idea. I would use a hash table. something like this:

dim htInputs as hashtable
htInputs.Add(dtrcondet.item("contact_detail_descri ption"), _
new textbox)

Later, you can access the textbox via:

dim mytextbox as textbox =
htInput(dtrcondet.item("contact_detail_description "))

*If you are bound and determined, see if there is a method in VB.Net that
corresponds to the vbscript Execute method, ie, a method that accepts a
string and executes it. Maybe Eval()?

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Oct 31 '05 #3
Slight change...

This is untested but it might be possible to make a new text box, set the
name, and then access with that name. Something like:
Dim curBox as TextBox
While dtrcondet.Read
curBox = new TextBox()
curBox.Name = dtrcondet.item("contact_detail_description")
Me.Controls.Add(curBox)
WEnd

You might then be able to access it by saying something like:
Me.Controls(dtrcondet.item("contact_detail_descrip tion"))

However:
You need to decide how to handle duplicate [name] values, and you'll need to
check for invalid characters - I can't remember if there are characters that
can't be used for names. It would still probably be best to use the .tag
property as previously discussed. How are you reading the values back in?
There are slightly differing options depending on whether it's a Win or Web
form.

Jevon
"Jevon" <pl****@ask.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
Is this a .net app? E.g. .ASPX? If so, this should really be posted in
microsoft.public.dotnet.framework.aspnet, or
microsoft.public.dotnet.languages.vb if it's a general thing - your post
isn't clear.

What you want to do isn't possible. However, a work around would be to
have a hashtable that you add the items to. When you make a new textbox,
you set the TAG property to the value of
dtrcondet.item("contact_detail_description"), then you can look in the
hashtable for the corresponding value. However, you might not even need
the hashtable, you could just use the TAG value.

Sorry if that's a bit unclear, but I can't figure out why you'd want
dynamic text boxes in that manner anyway, or what you're trying to do with
them :)

Jevon
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
I want to create textboxes dynamically but with dynamic names also.

i am retrieveing a load of values from a table in SQL into a DataReader.
Then i want to create textboxes from those variables. I want to dim
various
textboxes with different names depending on what I retrieve from SQL. I
tried the following:

dim dtrcondet.item("contact_detail_description") as new textbox()

but this does not work

Can anyone help?

----
Mark


Oct 31 '05 #4
Sorry for posting this in the wrong section, this is an ASP.NET 2.0 query, i
just saw web development and thought this would be the right section! :)

Jevon, your suggestion that you havent tested was what i was going to try
next! So i will give that a go in a bit. Instead of adding it to the page
controls, im going to add it to a placeholder, but it should still work.

If this works, im going to be so happy! Its being annoying me all day

Cheers

----
Mark
"Jevon" wrote:
Slight change...

This is untested but it might be possible to make a new text box, set the
name, and then access with that name. Something like:
Dim curBox as TextBox
While dtrcondet.Read
curBox = new TextBox()
curBox.Name = dtrcondet.item("contact_detail_description")
Me.Controls.Add(curBox)
WEnd

You might then be able to access it by saying something like:
Me.Controls(dtrcondet.item("contact_detail_descrip tion"))

However:
You need to decide how to handle duplicate [name] values, and you'll need to
check for invalid characters - I can't remember if there are characters that
can't be used for names. It would still probably be best to use the .tag
property as previously discussed. How are you reading the values back in?
There are slightly differing options depending on whether it's a Win or Web
form.

Jevon
"Jevon" <pl****@ask.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
Is this a .net app? E.g. .ASPX? If so, this should really be posted in
microsoft.public.dotnet.framework.aspnet, or
microsoft.public.dotnet.languages.vb if it's a general thing - your post
isn't clear.

What you want to do isn't possible. However, a work around would be to
have a hashtable that you add the items to. When you make a new textbox,
you set the TAG property to the value of
dtrcondet.item("contact_detail_description"), then you can look in the
hashtable for the corresponding value. However, you might not even need
the hashtable, you could just use the TAG value.

Sorry if that's a bit unclear, but I can't figure out why you'd want
dynamic text boxes in that manner anyway, or what you're trying to do with
them :)

Jevon
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
I want to create textboxes dynamically but with dynamic names also.

i am retrieveing a load of values from a table in SQL into a DataReader.
Then i want to create textboxes from those variables. I want to dim
various
textboxes with different names depending on what I retrieve from SQL. I
tried the following:

dim dtrcondet.item("contact_detail_description") as new textbox()

but this does not work

Can anyone help?

----
Mark



Oct 31 '05 #5
Jevon, your a genious!

Got it using this code, which is basically yours anyway!

Dim temptxt As TextBox
While dtrConDet.Read()
temptxt = New TextBox()
temptxt.ID = dtrConDet.Item("detail_type_description")
plaContDet.Controls.Add(temptxt)
End While

Now ive just gotta mess around with literals and formatting, but thats just
something messy to play with :)

Thank you so much, now my stress can be relieved! :)
--
Mark
"Jevon" wrote:
Slight change...

This is untested but it might be possible to make a new text box, set the
name, and then access with that name. Something like:
Dim curBox as TextBox
While dtrcondet.Read
curBox = new TextBox()
curBox.Name = dtrcondet.item("contact_detail_description")
Me.Controls.Add(curBox)
WEnd

You might then be able to access it by saying something like:
Me.Controls(dtrcondet.item("contact_detail_descrip tion"))

However:
You need to decide how to handle duplicate [name] values, and you'll need to
check for invalid characters - I can't remember if there are characters that
can't be used for names. It would still probably be best to use the .tag
property as previously discussed. How are you reading the values back in?
There are slightly differing options depending on whether it's a Win or Web
form.

Jevon
"Jevon" <pl****@ask.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
Is this a .net app? E.g. .ASPX? If so, this should really be posted in
microsoft.public.dotnet.framework.aspnet, or
microsoft.public.dotnet.languages.vb if it's a general thing - your post
isn't clear.

What you want to do isn't possible. However, a work around would be to
have a hashtable that you add the items to. When you make a new textbox,
you set the TAG property to the value of
dtrcondet.item("contact_detail_description"), then you can look in the
hashtable for the corresponding value. However, you might not even need
the hashtable, you could just use the TAG value.

Sorry if that's a bit unclear, but I can't figure out why you'd want
dynamic text boxes in that manner anyway, or what you're trying to do with
them :)

Jevon
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:E4**********************************@microsof t.com...
I want to create textboxes dynamically but with dynamic names also.

i am retrieveing a load of values from a table in SQL into a DataReader.
Then i want to create textboxes from those variables. I want to dim
various
textboxes with different names depending on what I retrieve from SQL. I
tried the following:

dim dtrcondet.item("contact_detail_description") as new textbox()

but this does not work

Can anyone help?

----
Mark



Oct 31 '05 #6
Glad I could help. Just remember you'll run into problems if there are any
duplicate descriptions :)

Jevon
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:2B**********************************@microsof t.com...
Jevon, your a genious!

Got it using this code, which is basically yours anyway!

Dim temptxt As TextBox
While dtrConDet.Read()
temptxt = New TextBox()
temptxt.ID = dtrConDet.Item("detail_type_description")
plaContDet.Controls.Add(temptxt)
End While

Now ive just gotta mess around with literals and formatting, but thats
just
something messy to play with :)

Thank you so much, now my stress can be relieved! :)
--
Mark
"Jevon" wrote:
Slight change...

This is untested but it might be possible to make a new text box, set the
name, and then access with that name. Something like:
Dim curBox as TextBox
While dtrcondet.Read
curBox = new TextBox()
curBox.Name = dtrcondet.item("contact_detail_description")
Me.Controls.Add(curBox)
WEnd

You might then be able to access it by saying something like:
Me.Controls(dtrcondet.item("contact_detail_descrip tion"))

However:
You need to decide how to handle duplicate [name] values, and you'll need
to
check for invalid characters - I can't remember if there are characters
that
can't be used for names. It would still probably be best to use the .tag
property as previously discussed. How are you reading the values back in?
There are slightly differing options depending on whether it's a Win or
Web
form.

Jevon
"Jevon" <pl****@ask.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
> Is this a .net app? E.g. .ASPX? If so, this should really be posted in
> microsoft.public.dotnet.framework.aspnet, or
> microsoft.public.dotnet.languages.vb if it's a general thing - your
> post
> isn't clear.
>
> What you want to do isn't possible. However, a work around would be to
> have a hashtable that you add the items to. When you make a new
> textbox,
> you set the TAG property to the value of
> dtrcondet.item("contact_detail_description"), then you can look in the
> hashtable for the corresponding value. However, you might not even need
> the hashtable, you could just use the TAG value.
>
> Sorry if that's a bit unclear, but I can't figure out why you'd want
> dynamic text boxes in that manner anyway, or what you're trying to do
> with
> them :)
>
> Jevon
>
>
> "Mark" <Ma**@discussions.microsoft.com> wrote in message
> news:E4**********************************@microsof t.com...
>>I want to create textboxes dynamically but with dynamic names also.
>>
>> i am retrieveing a load of values from a table in SQL into a
>> DataReader.
>> Then i want to create textboxes from those variables. I want to dim
>> various
>> textboxes with different names depending on what I retrieve from SQL.
>> I
>> tried the following:
>>
>> dim dtrcondet.item("contact_detail_description") as new textbox()
>>
>> but this does not work
>>
>> Can anyone help?
>>
>> ----
>> Mark
>
>


Nov 1 '05 #7
Yea thats why i have now used the contact_type_id instead of the description,
so it should be fine now.

Thanks

--
Mark
"Jevon" wrote:
Glad I could help. Just remember you'll run into problems if there are any
duplicate descriptions :)

Jevon
"Mark" <Ma**@discussions.microsoft.com> wrote in message
news:2B**********************************@microsof t.com...
Jevon, your a genious!

Got it using this code, which is basically yours anyway!

Dim temptxt As TextBox
While dtrConDet.Read()
temptxt = New TextBox()
temptxt.ID = dtrConDet.Item("detail_type_description")
plaContDet.Controls.Add(temptxt)
End While

Now ive just gotta mess around with literals and formatting, but thats
just
something messy to play with :)

Thank you so much, now my stress can be relieved! :)
--
Mark
"Jevon" wrote:
Slight change...

This is untested but it might be possible to make a new text box, set the
name, and then access with that name. Something like:
Dim curBox as TextBox
While dtrcondet.Read
curBox = new TextBox()
curBox.Name = dtrcondet.item("contact_detail_description")
Me.Controls.Add(curBox)
WEnd

You might then be able to access it by saying something like:
Me.Controls(dtrcondet.item("contact_detail_descrip tion"))

However:
You need to decide how to handle duplicate [name] values, and you'll need
to
check for invalid characters - I can't remember if there are characters
that
can't be used for names. It would still probably be best to use the .tag
property as previously discussed. How are you reading the values back in?
There are slightly differing options depending on whether it's a Win or
Web
form.

Jevon
"Jevon" <pl****@ask.com> wrote in message
news:Ou**************@TK2MSFTNGP10.phx.gbl...
> Is this a .net app? E.g. .ASPX? If so, this should really be posted in
> microsoft.public.dotnet.framework.aspnet, or
> microsoft.public.dotnet.languages.vb if it's a general thing - your
> post
> isn't clear.
>
> What you want to do isn't possible. However, a work around would be to
> have a hashtable that you add the items to. When you make a new
> textbox,
> you set the TAG property to the value of
> dtrcondet.item("contact_detail_description"), then you can look in the
> hashtable for the corresponding value. However, you might not even need
> the hashtable, you could just use the TAG value.
>
> Sorry if that's a bit unclear, but I can't figure out why you'd want
> dynamic text boxes in that manner anyway, or what you're trying to do
> with
> them :)
>
> Jevon
>
>
> "Mark" <Ma**@discussions.microsoft.com> wrote in message
> news:E4**********************************@microsof t.com...
>>I want to create textboxes dynamically but with dynamic names also.
>>
>> i am retrieveing a load of values from a table in SQL into a
>> DataReader.
>> Then i want to create textboxes from those variables. I want to dim
>> various
>> textboxes with different names depending on what I retrieve from SQL.
>> I
>> tried the following:
>>
>> dim dtrcondet.item("contact_detail_description") as new textbox()
>>
>> but this does not work
>>
>> Can anyone help?
>>
>> ----
>> Mark
>
>


Nov 1 '05 #8

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

Similar topics

11
by: KaHuNa | last post by:
I want create a string from a row of my db, but for each rows i need a new string and a new name for the variable. exemple: int i = myRow; string varName = "news"; createNameVar = varName +...
16
by: pukivruki | last post by:
hi, I wish to create a temporary table who's name is dynamic based on the argument. ALTER PROCEDURE . @PID1 VARCHAR(50), @PID2 VARCHAR(50), @TICKET VARCHAR(20)
1
by: dibbes | last post by:
Hi, I'm getting creazy with this problem and I hope somebody can give me the reason why it's going wrong or even better, the solution. I'm having a form what is generated dynamic.The names of...
1
by: Steve | last post by:
Hi All, I have an Excel file being delivered to a shared drive where I only have read access on a daily basis. The files arrive in the following format 'Filename+timestamp.xls' Example:...
6
by: sathyashrayan | last post by:
Dear Group, Please look at the following demo link. http://www.itsravi.com/demo/new_pms/admin/addproject.php
3
by: andrewteg | last post by:
I have some variables in the session object that have the same naming convention like so: form1Var1, form1Var2, form1Var3... form2Var1, form2Var2, form2Var3... I need to use all of them in a...
3
by: Promedeus | last post by:
.NET Version: 3.5 Ok, I recieve an error (System.InvalidCastException was unhandled. Message="Unable to cast object of type 'System.Windows.Forms.Control' to type 'System.Windows.Forms.Label'.")...
6
by: mabrynda | last post by:
Dear Experts, I have the following problem. I'm generating output txt files from access (an access 2002 table is converted into deleimited text with tabs including field names). For that I have a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.