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

using controls loop...

Hi There..
I have dynamically created some textbox and checkbox controls by adding them
to a panel. Now I would like to get the values out.
I have created a
for each loop that I can see the controls Unique ID with. But I for the
life of me can't figure out how to see the value the control is storing.
Could somebody please help me. I'm thinking that I might need to use
something like "findcontrol", but this wouldn't make sense to me.

This is what I would ideally like.
for each xcontrol in xPanels.controls
response.write me(xControl).Value
Next

But this doesn't seem to work.
Many Thanks for some help.
Kez.
Nov 19 '05 #1
3 1309
Depending on when you create the controls, their state may not be updated to
reflect any client-side changes. You could either move the creation of the
controls earlier in the page's life cycle or use Request.Form.

You may want to read
http://msdn.microsoft.com/library/de...bjectmodel.asp
for more information about how/when control state is updated.

FindControl should be able to get you a reference to the control but again,
it depends on when you call FindControl and when you create the controls.

HTH
----------------
Dave Fancher
http://www.davefancher.com

"Kezza" <Ke***@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
Hi There..
I have dynamically created some textbox and checkbox controls by adding
them
to a panel. Now I would like to get the values out.
I have created a
for each loop that I can see the controls Unique ID with. But I for the
life of me can't figure out how to see the value the control is storing.
Could somebody please help me. I'm thinking that I might need to use
something like "findcontrol", but this wouldn't make sense to me.

This is what I would ideally like.
for each xcontrol in xPanels.controls
response.write me(xControl).Value
Next

But this doesn't seem to work.
Many Thanks for some help.
Kez.

Nov 19 '05 #2
Thanks Dave

Are you saying that my loop

for each xcontrol in xPanels.controls
response.write me(xControl).Value
Next

and syntax should work, if I have declared the controls early enough.
I am creating them on pageload by the way.

Thanks
Kez.
"Dave Fancher" wrote:
Depending on when you create the controls, their state may not be updated to
reflect any client-side changes. You could either move the creation of the
controls earlier in the page's life cycle or use Request.Form.

You may want to read
http://msdn.microsoft.com/library/de...bjectmodel.asp
for more information about how/when control state is updated.

FindControl should be able to get you a reference to the control but again,
it depends on when you call FindControl and when you create the controls.

HTH
----------------
Dave Fancher
http://www.davefancher.com

"Kezza" <Ke***@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
Hi There..
I have dynamically created some textbox and checkbox controls by adding
them
to a panel. Now I would like to get the values out.
I have created a
for each loop that I can see the controls Unique ID with. But I for the
life of me can't figure out how to see the value the control is storing.
Could somebody please help me. I'm thinking that I might need to use
something like "findcontrol", but this wouldn't make sense to me.

This is what I would ideally like.
for each xcontrol in xPanels.controls
response.write me(xControl).Value
Next

But this doesn't seem to work.
Many Thanks for some help.
Kez.


Nov 19 '05 #3
Your loop or FindControl() should find the controls and their values just
fine since you're creating them in PageLoad.

I'm sorry I didn't notice this earlier but one thing to note is that each
control uses a different property to access the value it contains.
TextBoxes for instance, use the Text property.

CheckBoxes and RadioButtons are a little more tricky though because they
don't have a "value" property despite the presence of one in HTML. The
"value" of a check box or radio button is "Checked" or "Unchecked" and is
implemented through the boolean Checked property.

To overcome the limitation of the CheckBoxes and RadioButtons, you could
derive a new control from the CheckBox and RadioButton classes called
ValuedCheckBox or ValuedRadioButton respectively and add a Value property OR
you could fall back on the trusty Request.Forms collection.

Now, keeping this all in mind, in order to retrieve the value for the
controls, you'll need to convert the control to the appropriate type since
the property won't be accessible through the Control class. I'm not a VB
expert but you'll accomplish the conversion using the CType command if I'm
not mistaken. Obviously, you'll need to test for the type before you do the
conversion and call the appropriate code for the type. I'm sure there's a
VB shortcut for the test but you could use Object.ReferenceEquals if you
need something quick.

HTH
----------------
Dave Fancher
http://www.davefancher.com

"Kezza" <Ke***@discussions.microsoft.com> wrote in message
news:CB**********************************@microsof t.com...
Thanks Dave

Are you saying that my loop

for each xcontrol in xPanels.controls
response.write me(xControl).Value
Next

and syntax should work, if I have declared the controls early enough.
I am creating them on pageload by the way.

Thanks
Kez.
"Dave Fancher" wrote:
Depending on when you create the controls, their state may not be updated
to
reflect any client-side changes. You could either move the creation of
the
controls earlier in the page's life cycle or use Request.Form.

You may want to read
http://msdn.microsoft.com/library/de...bjectmodel.asp
for more information about how/when control state is updated.

FindControl should be able to get you a reference to the control but
again,
it depends on when you call FindControl and when you create the controls.

HTH
----------------
Dave Fancher
http://www.davefancher.com

"Kezza" <Ke***@discussions.microsoft.com> wrote in message
news:65**********************************@microsof t.com...
> Hi There..
> I have dynamically created some textbox and checkbox controls by adding
> them
> to a panel. Now I would like to get the values out.
> I have created a
> for each loop that I can see the controls Unique ID with. But I for
> the
> life of me can't figure out how to see the value the control is
> storing.
> Could somebody please help me. I'm thinking that I might need to use
> something like "findcontrol", but this wouldn't make sense to me.
>
> This is what I would ideally like.
> for each xcontrol in xPanels.controls
> response.write me(xControl).Value
> Next
>
> But this doesn't seem to work.
> Many Thanks for some help.
> Kez.


Nov 19 '05 #4

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

Similar topics

3
by: DBQueen | last post by:
I have a form with lines of controls. On some of the lines there are 3 controls (call them A,B,C); other lines have only control A. The controls have been numbered sequentially (Q20, Q21....Q76)...
4
by: Ryan Liu | last post by:
How to loop though controls on the form? I set each control's TabStop and TabIndex, but at run time, I press Tab key, it jump though first control to last control and does not go back to the...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
9
by: Merlin | last post by:
Hi, My code below doesn't work does anyone have any pointers? All my controls are programically added. Dim i As Int16 For i = 0 To Me.Controls.Count - 1 If Me.Controls(i).Name <>...
66
by: Cor | last post by:
Hi, I start a new thread about a discussion from yesterday (or for some of us this morning). It was a not so nice discussion about dynamically removing controls from a panel or what ever. It...
3
by: Rob | last post by:
Hi all, I am having trouble converting the code below (found on http://vbnet.mvps.org/index.html?code/core/sendmessage.htm) into a format that will work using vb .NET. Can anyone have a look...
8
by: dominique | last post by:
Hi, Is it possible (in vb.net with WinForms) to loop throw controls inside a container (form or panel) sorting the controls on a property (.tabindex for example) ? My problem : on several...
2
by: james | last post by:
As part of my app I am programatically adding some Label controls to a form at runtime. The code for these is part of a function that is overrriding the Paint event of the form. The other stuff...
3
by: Ken Fine | last post by:
I'm interested in programmatically manipulating groups of ASP.NET controls by type. Can someone suggest code for the following? Loop through, say, all label controls on a page, and assigning a...
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.