Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Is there a way to validate date entered by a user in Gridview without converting to Templatefield?

Posted on 2014-12-28
5
Medium Priority
?
134 Views
Last Modified: 2015-01-28
Hi, I'm using VS2012.
Is there a way to validate user's date input in the gridview (it's the last column).  There 6 columns, the first is the Edit(auto generated) and the last one is date time type with display format to show only short date.  The grid is datagind,    Is there a way to validate when user modify the date/time column, only date is modified, when they click the Update button?  
The problem is if I convert it to Template field then I lose the ability to format the dispaly to only short date, it would display the entire date and time.  It's okay if I can find a regular expression that does the job but i can't find one that would validate mm/dd/yyyy hh:mm:ss AM/PM.

Thank you
0
Comment
Question by:lapucca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
dejaanbu earned 2000 total points
ID: 40521300
The problem is if I convert it to Template field then I lose the ability to format the dispaly to only short date,
You can specify format right in Eval expression:  Text='<%# Eval("yourDateColumn", "{0:d}") %>'
Or else specify DataFormatString="{0:d}"
make sure ApplyFormatInEditMode = True
0
 
LVL 2

Expert Comment

by:M. Atif Nadeem
ID: 40521414
Hi buddy,

For bounding columns, try this code snippet:

var dataTable = new DataTable();
dataTable.Columns.Add("BDate", typeof(DateTime));
dataGridView1.DataSource = dataTable;

Open in new window


Cheers
0
 

Author Comment

by:lapucca
ID: 40527112
I want to validate the data that users enter, not when data is binding.  Thank you,
0
 

Author Comment

by:lapucca
ID: 40566895
I accepted the 1st solution because it actually works.  Please grant expert credit, close this question and re-instate my ability to post more question.  Thank you.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question