Validation advice

  • Thread starter Thread starter CK
  • Start date Start date
C

CK

Hi all,
I have a drop down list that is populated from a database table. During the
databind event I add a row to the beginning of the datatable and set that as
the source of the dropdown. it's value is "0".

I added a CompareValidator to make sure when the web form is submitted, that
the value of the drop down is greater than 0. Everything works great.

My question is, is it more appropriate to use a RequiredFieldValidator? If
so why? I thought this was a good use for the compare validator but my
development team thinks the RequiredFieldValidator is more appropriate.

Any comments are appreciated.

TIA,
CK
 
Hi,
Its fine with comparevalidator too...

But you can also use RequiredFieldValidator .... by setting its initial
value to 0

both provide functionality to place a check .... but its you choice which
you select
 
I would agree with your dev team and a good reason is for that maintenance
of the app. You may need to add another ListItem with a value of 0 somewhere
down the line. With a ListItem("name","") and a required validator, you'll
never need to ever change the code.
 

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

Back
Top