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 8767523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:50:14+00:00 2026-06-13T16:50:14+00:00

How can I check the date I pick from a DateTimePicker control exists in

  • 0

How can I check the date I pick from a DateTimePicker control exists in a SQL table?

I have a DateTimePicker on my ASP.NET page where I can select a date. I need to check if this selected date exists in a SQL table (in a table called blockdate). If the selected date does exist, I need to enter the corresponding values from the date and reason columns in the blockdate table into a DataGridView.

Can anybody tell me how I can do this?

This is the code I have so far to check if the selected date is a weekend.

DatePicker.SelectedDate.ToString("dd-MM-yyyy");
DateTime date = DatePicker.SelectedDate.Date;
DateTime weekend;

if (date.DayOfWeek == DayOfWeek.Saturday)
{
    weekend = date.AddDays(+2);
}

if (date.DayOfWeek == DayOfWeek.Sunday)
{
    weekend = date.AddDays(+1);
}
else
{
    weekend = date;
}
  • 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. Editorial Team
    Editorial Team
    2026-06-13T16:50:15+00:00Added an answer on June 13, 2026 at 4:50 pm

    I think calling the database on every time when the DatePicker values change not going to be an ideal solution.

    You can select all the dates from you sql table to a list in pageload.

    var dateList = new List<DateTime>();
    dateList = //all the dates from you sql table
    

    Then when the DatePicker value changed, you can match the value against your list.

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Timezone from geolocation I have a website where people can check in
In my date picker i can select a date from the list. I save
In my date picker i can select a date from the list. I save
How I can check the date using a calender , what I want to
I have a check box list in that user can check or uncheck the
I am trying to check a date format to see if I can check
I have a DataTable according to the Client Requirement it can contain invalid date
I realize that you can check if a Date is inDaylightTime , but how
Any Java API in client side can check its modified date?
How can I check if date is in given format or not. It must

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.