By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,375 Members | 3,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,375 IT Pros & Developers. It's quick & easy.

Problem with RadioButton

P: n/a
RadioButton have property Checked (true or false).
If I make RadioButtons with code, without drawing by mouse than I have
problems. I write like this:

Dim rb(0 To 2) As RadioButton
Dim n As Integer

For n = 0 To 2
rb(n) = New RadioButton
rb(n).Text = "Text: " + CStr(n)
Panel1.Controls.Add(rb(n))
Next
Session("rb") = rb
Than I call this RadioButton array from session to other procedure:

Dim rb(0 To 2) As RadioButton
rb = Session("rb")
Response.Write(rb(0).Checked)
Response.Write(rb(1).Checked)
Response.Write(rb(2).Checked)
Problem is next: Every RadioButton have property Checked=False even when
user check some button. Text property is ok, but checked property is False
every time.

How to fix it?
Dec 29 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Igor,

You are taking the behaviour from a checkbox.

There will only be one radiobutton in a control that can have the value
true..

(If you absolutely don't want checkboxes than you can set every radiobutton
in a groupbox (so for 3 buttons you have 3 groupboxes)). I would not do it,
because a radiobutton is a radiobutton wich is on or off.

Cor
<ig**@nesalji.hrschreef in bericht news:en**********@sunce.iskon.hr...
RadioButton have property Checked (true or false).
If I make RadioButtons with code, without drawing by mouse than I have
problems. I write like this:

Dim rb(0 To 2) As RadioButton
Dim n As Integer

For n = 0 To 2
rb(n) = New RadioButton
rb(n).Text = "Text: " + CStr(n)
Panel1.Controls.Add(rb(n))
Next
Session("rb") = rb
Than I call this RadioButton array from session to other procedure:

Dim rb(0 To 2) As RadioButton
rb = Session("rb")
Response.Write(rb(0).Checked)
Response.Write(rb(1).Checked)
Response.Write(rb(2).Checked)
Problem is next: Every RadioButton have property Checked=False even when
user check some button. Text property is ok, but checked property is False
every time.

How to fix it?


Dec 29 '06 #2

P: n/a
(If you absolutely don't want checkboxes than you can set every
radiobutton in a groupbox (so for 3 buttons you have 3 groupboxes)). I
would not do it, because a radiobutton is a radiobutton wich is on or off.
Problem is not group property. It is not written in my code here, but it is
shorter code. I have one groupname for more checkboxes. Problem is that I
don't know how to pick checked property from radiobuttoncontrols which is
not added by mouse. Controls was addes by code in one procedure. In other
procedure I don't view this controll array. If I put this in session in
first procedure than radiobuttons are not checked because it is procedure
for drowing and user will check it on page after drowing (after program
exits from drowing procedure). How to view in other procedure which
radiobutton is checked?
Dec 29 '06 #3

P: n/a
Oh, no! Nobody knows this!
How to find some control which is added by code (new instance od object on
page). How to pick some property of some control which is added by user at
run time? Can I find it with FindControl method? How to use findcontrol
method? Please help!


Dec 29 '06 #4

P: n/a
Igor,

What your code probably does is setting the previous button of by setting
the next. There is not something as a group radiobutton. They are all
groupbuttons from the page as long as they are not set in a special group.

Cor


"Igor" <ig**@nesalji.hrschreef in bericht
news:en**********@sunce.iskon.hr...
Oh, no! Nobody knows this!
How to find some control which is added by code (new instance od object
on page). How to pick some property of some control which is added by user
at run time? Can I find it with FindControl method? How to use findcontrol
method? Please help!


Dec 29 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.