Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 67241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:13:44+00:00 2026-05-10T19:13:44+00:00

I have a textbox with the Text property bound to a dataset column with

  • 0

I have a textbox with the Text property bound to a dataset column with the DataType set to System.DateTime.
The FormatString on the Binding is set to dd-MM-yyyy.

When the user enters a date it attempts to convert it to a date but can come up with some strange values for a seemingly invalid date.

For example:

textBox1.Text = '01-02-200'; 

Should be an invalid date but it formats it as 01-02-0200.

Is there an easy way to catch these out-of-bounds values either through setting a valid range or overriding an event on the binding/textbox?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:13:45+00:00Added an answer on May 10, 2026 at 7:13 pm

    A .NET DateTime is in the range 01/01/0001 to 31/12/9999 23:59:59.9999999, so 01/01/200 is considered to be valid.

    You can validate the input and restrict the range: the Validating event would be the place to do your validation. You’ll need to parse the string into a DateTime and validate its range.

    The allowed range will be application dependent. For example, the following code will restrict the datetime to values that can be stored in a SQL Server 2005 DATETIME column (01-01-1753 to 31-12-999):

    private void textBox1_Validating(object sender, CancelEventArgs e) {     DateTime date;     if (!DateTime.TryParseExact(textBox1.Text,          'dd-MM-yyyy',          CultureInfo.CurrentCulture,          DateTimeStyles.None,          out date))     {         MessageBox.Show(textBox1.Text + ' is not a valid date');         textBox1.Focus();         e.Cancel = true;         return;     }     if ((date < (DateTime) System.Data.SqlTypes.SqlDateTime.MinValue) ||         (date > (DateTime) System.Data.SqlTypes.SqlDateTime.MaxValue))     {         MessageBox.Show(textBox1.Text + ' is out of range');         textBox1.Focus();         e.Cancel = true;         return;     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 73k
  • Answers 73k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Unknown domains that come into apache over the specified ip… May 11, 2026 at 1:54 pm
  • added an answer >>> L1 = [2,3,4] >>> L2 = [1,2] >>> [i… May 11, 2026 at 1:54 pm
  • added an answer You can try moving the buffer area. For example: Console.WriteLine('Top')… May 11, 2026 at 1:54 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.