473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Validating Dates In GridView

Hi people.

I am attempting to determine how best to prevent a users date entry in an
update action from causing a format exception. The dates are UK, but the
user may try to put in a 'US' format.

I have a datasource which is wired to my DAL/update function.

1.) On the server side.

Where do I need to check this ?

2.) On the client side.

If I wanted to set up JSCRIPT validation, whats the best way to acheive this
?
I dont neccesarilly need fine detail, but a broad brush roadmap of what to
do and Ill work it out from there.

Thanks. !

Mar 21 '08 #1
2 1585
Ahh, dont worry. Ive found a way.

Basic Steps to enable this of client side ( Per Text Input ) is this.

1.) Handle GridView1_RowDataBound

2.) Find and cast the required textbox to a textbox.

3.) Add an attribute("onkeypress","yourDateFormatValidationFu nction");

I still need to validate on the server that the actual date exists, but
thats not going to be too troublesome.

Cheers
"Just Me" <news.microsoft.comwrote in message
news:OX**************@TK2MSFTNGP02.phx.gbl...
Hi people.

I am attempting to determine how best to prevent a users date entry in an
update action from causing a format exception. The dates are UK, but the
user may try to put in a 'US' format.

I have a datasource which is wired to my DAL/update function.

1.) On the server side.

Where do I need to check this ?

2.) On the client side.

If I wanted to set up JSCRIPT validation, whats the best way to acheive
this ?
I dont neccesarilly need fine detail, but a broad brush roadmap of what to
do and Ill work it out from there.

Thanks. !

Mar 21 '08 #2
On 21 Mar, 19:28, "Just Me" <news.microsoft.comwrote:
Hi people.

I am attempting to determine how best to prevent a users date entry in an
update action from causing a format exception. The dates are UK, but the
user may try to put in a 'US' format.

I have a datasource which is wired to my DAL/update function.

1.) On the server side.

Where do I need to check this ?

2.) On the client side.

If I wanted to set up JSCRIPT validation, whats the best way to acheive this
?

I dont neccesarilly need fine detail, but a broad brush roadmap of what to
do and Ill work it out from there.

Thanks. !
Hi

Use a CompareValidator control for a client-side check prior to
postback. Set the 'operator' (properties window) property to
DataTypeCheck. You can use this in conjunction with a RangeValidator
to filter on the required period if applicable.

Unfortunately there is no way to guarantee day/month v month/day
ambiguity for text input. Most web sites that require date input use
drop-down lists for day and month instead.

Alternatively use the ASP.NET calendar control. They require more
space on the page and can generate a lot of round trips during the
selection process but are user friendly and easy to work with on the
development side.

HTH
Mar 21 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steve | last post by:
I am currently trying to validate data in an access database. I need to verify that columns containing date information are in the format ddmmyyyy and columns containg time information are in the...
4
by: John Livermore | last post by:
In C# what is the best way to validate that a particular string entered by a user will actually convert to a date w/o using a try catch block or writing code to explicitly parse the string? Here...
4
by: John | last post by:
Hi I have a web control text box on my webform which I want to use for entering dates. Is there a way to validate this text box field for valid dates? May be using a validators such as regular...
11
by: tshad | last post by:
I have 4 dropdown boxes (fromDay, fromMonth, ToDay and ToMonth) I want to be able to test to make sure that the dates are valid and the the From dates are < the To dates. When I add the...
3
by: thechaosengine | last post by:
Hi all, I'm having trouble getting dates to display in the right format in my GridView. I'd like it to appear in the UK format - just the date, not the time, but I'm not having any luck. ...
0
by: Mike P | last post by:
How do you validate seperate controls in a gridview against each other? I have several controls that I need to compare the values of against each other in my gridview on editing. Any assistance...
4
by: =?Utf-8?B?dHJldmk=?= | last post by:
hi, I've got a gridviw that has fields that relate to datefields, actually I only care about the time in these fields. I display them as drop-down lists so user can change the date when in edit...
3
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I have a gridview that uses a sqldatasource. The rows of the gridview are editable. When the gridview is in edit mode, one of the columns is a dropdown. In testing the editing, I deleted the...
0
by: bob | last post by:
Hi, Further to my previous wailing, has ANYBODY successfully put a date into a gridview databound column and managed to retrieve it back into a variable?? If so I would love to hear about it....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.