Passing parameters to gridview

M

Mike P

I am entering two dates into textboxes and using them as control
parameters in an SQL DataSource which is being used to populate a
gridview. I am using a custom validator to check if the data entered
into the text boxes are valid dates, but even when my code captures that
they are not valid dates it seems like it still tries to populate the
gridview and in doing so gives me the error 'Conversion failed when
converting datetime from character string'.

How can I prevent these parameters being passed to the gridview if they
are invalid?
 
R

Rad [Visual C# MVP]

I am entering two dates into textboxes and using them as control
parameters in an SQL DataSource which is being used to populate a
gridview. I am using a custom validator to check if the data entered
into the text boxes are valid dates, but even when my code captures that
they are not valid dates it seems like it still tries to populate the
gridview and in doing so gives me the error 'Conversion failed when
converting datetime from character string'.

How can I prevent these parameters being passed to the gridview if they
are invalid?

Rather than wrestling with date validation I suggest you get a good
JavaScript calendar implementation that will save you from the
headaches of validation of dates and internationalization data format
issues.

As for your problem maybe if you posted the code that processes the
dates we could be better placed to understand the error
 

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,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top