radio button list doesn't hold value?

K

KathyB

Hi. I have a radio button list with list items assigned via a
datareader from a database. Everything looks fine, the items are there
on page load, I can click one, etc. There is also a required validator
on the list.

However, when I hit SUBMIT, the selection disappears so the first line
of my submit click code (If Page.IsValid = True Then)...is always
"false" and nothing happens of course.

I'm probably just tired of staring at it, but how does this happen?

Thanks again. Kathy
 
J

John Saunders

KathyB said:
Hi. I have a radio button list with list items assigned via a
datareader from a database. Everything looks fine, the items are there
on page load, I can click one, etc. There is also a required validator
on the list.

However, when I hit SUBMIT, the selection disappears so the first line
of my submit click code (If Page.IsValid = True Then)...is always
"false" and nothing happens of course.

I'm probably just tired of staring at it, but how does this happen?

Kathy,

As an experiment, try removing the RequiredFieldValidator, then, on
PostBack, check to see if you can change RadioButtonList.SelectedItem. I'd
also suggest turning on page tracing and look to see what gets posted back
for the RadioButtonList.
 
C

Craig Deelsnyder

Make sure you're using the check for IsPostBack in your Page_Load as
appropriate. You don't want to rebind your button list datasource
everytime, it should be in a check:

If Not IsPostBack Then
'create datasource/bind to list
End If

in Page_Load. As well as any other setup that is only to be run once....
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top