RequiredFieldValidator on a ListBox

K

Kristian Kaadner

Hi.

I use asp.net 2.0 adn add data to a listbox dynamically like this:

Dim lb as listbox
lb = formview1.FindControl("ListBox1")
lb.DataSourceID = "sqlDataSource1"
lb.DataTextField = "Name"
lb.DataValueField = "ID"
lb.DataBind()

But I use a requiredfieldvalidator on ListBox1, and when the data is added
dynamically, it fires when I submit the page, giving me the error message I
defined. If I add data to my listbox in another way, for example by selected
a value in a dropdownlist, the requiredfieldvalidator works.

How can I get get around this?

Best regards
Kris
 
C

Christopher Reed

In whatever method you're using to dynamically add data, you could turn off
client-side validation by setting the RFV.EnableClientScript to false.
 

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
474,263
Messages
2,571,064
Members
48,769
Latest member
Clifft

Latest Threads

Top