Change RadioButtonList Attributes

T

tshad

Is there a to change just one radio button in a list just after DataBinding
but before send the page to the user?

For example:

RFPServiceTypes.DataSource = myDbObject.RunProcedure("GetRFPServiceTypes",
parameters)
RFPServiceTypes.DataTextField = "Description"
RFPServiceTypes.DataBind()
RFPServiceTypes.Items.Insert(0, "All Services")

That is my RadioButtonList where I add "All Services" to the top of the
list.

I want to be able to set the attributes OnSelectedIndexChanged and
AutoPostback so that if the user clicks the first radio button, all the
others get selected also.

But I only want to do it for the first button and not all of them.

Can this be done?

Thanks,

Tom
 
T

tshad

My mistake. This is a CheckBoxList. This would make no sense with a
RadioButtonList. How can you do it (if it can be done) with a CheckBoxList?
 
S

S. Justin Gengo

Tshad,

In the post back event just use an if then to check if the first checkbox
has been checked. If it has, then check all the others.

If MyCheckBoxList.Items(0).Selected Then
Dim ItemCount, ItemLoop As Int32
ItemCount = MyCheckBoxList.Items.Count - 1

'---Start loop at 1 instead of zero to skip first checkbox
For ItemLoop = 1 To ItemCount
MyCheckBoxList.Items.Item(ItemLoop).Selected = True
Next
End If

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
T

tshad

S. Justin Gengo said:
Tshad,

In the post back event just use an if then to check if the first checkbox
has been checked. If it has, then check all the others.

The problem is that I don't want the others to post back. Only the Select
All Checkbox. That was why I wanted to put autopostback only on the first
one. I solved the problem by just creating one Checkbox for Select All and
the rest in the Checkboxlist and then I can put the autopostback only on
that checkbox.

I would still be interested if there is a way to set an attribute to only
one of the checkboxes in a list (in this case the first one, that I add
after I do the databind).

Thanks,

Tom
 
S

S. Justin Gengo

Tom,

The only way I can think of would be to write a javascript that would fire
when a checkbox is selected. Then an if then in the javascript could check
if it's the first checkbox that's selected. I know you're taking a look at
my checkboxlist required field validator control. The javascript in that
could be converted to do this.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top