473,327 Members | 1,930 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,327 software developers and data experts.

DateTime in dropdown

Hi all

The date values in my dropdown list appear as mm/dd/yyyy
Specifically, the day always contains 2 digits.
I need to set the selected index of the dropdown to the date that
equals another date value that does not use 2 digits for the day, if
the day is less that 10.
example
ddlBeginDate.SelectedIndex =
ddlBeginDate.Items.IndexOf(ddlBeginDate.Items.Find ByText(someClass.BeginDate.ToShortDateString()));

does not work when the list contains 10/07/2006
and the value returned by someClass.BeginDate.ToShortDateString() is
10/7/2006

How can I set this list value to be the date returned frm the class?

Thanks
Jeff
Oct 26 '06 #1
5 3842
Jeff,

Does the value have to be stored in SelectedIndex or could you
subscribe to the SelectedIndexChanged event, and when you catch the
event do the processing needed to remove the extra digit and place it
into another variable.

Jeff User wrote:
Hi all

The date values in my dropdown list appear as mm/dd/yyyy
Specifically, the day always contains 2 digits.
I need to set the selected index of the dropdown to the date that
equals another date value that does not use 2 digits for the day, if
the day is less that 10.
example
ddlBeginDate.SelectedIndex =
ddlBeginDate.Items.IndexOf(ddlBeginDate.Items.Find ByText(someClass.BeginDate.ToShortDateString()));

does not work when the list contains 10/07/2006
and the value returned by someClass.BeginDate.ToShortDateString() is
10/7/2006

How can I set this list value to be the date returned frm the class?

Thanks
Jeff
Oct 26 '06 #2

The dropdown is a list of dates. I have to find the index of the date
desired to set it as the selected item in the list. The desired value
being the date with only the 1 digit for the day, the list items being
the dates with 2 digits. I spose I can add the zero to the 1 digit day
to make it match the dropdown date format.
I was wondering if there was some way to use formating to get one to
look like the other.

Thanks

On 26 Oct 2006 10:31:09 -0700, "justin creasy"
<ju***********@gmail.comwrote:
>Jeff,

Does the value have to be stored in SelectedIndex or could you
subscribe to the SelectedIndexChanged event, and when you catch the
event do the processing needed to remove the extra digit and place it
into another variable.

Jeff User wrote:
>Hi all

The date values in my dropdown list appear as mm/dd/yyyy
Specifically, the day always contains 2 digits.
I need to set the selected index of the dropdown to the date that
equals another date value that does not use 2 digits for the day, if
the day is less that 10.
example
ddlBeginDate.SelectedIndex =
ddlBeginDate.Items.IndexOf(ddlBeginDate.Items.Fin dByText(someClass.BeginDate.ToShortDateString()));

does not work when the list contains 10/07/2006
and the value returned by someClass.BeginDate.ToShortDateString() is
10/7/2006

How can I set this list value to be the date returned frm the class?

Thanks
Jeff
Oct 26 '06 #3
Have you play with the Regional and Language Options in Control Panel and
see what is the effect?

chanmm

"Jeff User" <je*******@hotmail.comwrote in message
news:fd********************************@4ax.com...
>
The dropdown is a list of dates. I have to find the index of the date
desired to set it as the selected item in the list. The desired value
being the date with only the 1 digit for the day, the list items being
the dates with 2 digits. I spose I can add the zero to the 1 digit day
to make it match the dropdown date format.
I was wondering if there was some way to use formating to get one to
look like the other.

Thanks

On 26 Oct 2006 10:31:09 -0700, "justin creasy"
<ju***********@gmail.comwrote:
>>Jeff,

Does the value have to be stored in SelectedIndex or could you
subscribe to the SelectedIndexChanged event, and when you catch the
event do the processing needed to remove the extra digit and place it
into another variable.

Jeff User wrote:
>>Hi all

The date values in my dropdown list appear as mm/dd/yyyy
Specifically, the day always contains 2 digits.
I need to set the selected index of the dropdown to the date that
equals another date value that does not use 2 digits for the day, if
the day is less that 10.
example
ddlBeginDate.SelectedIndex =
ddlBeginDate.Items.IndexOf(ddlBeginDate.Items.Fi ndByText(someClass.BeginDate.ToShortDateString())) ;

does not work when the list contains 10/07/2006
and the value returned by someClass.BeginDate.ToShortDateString() is
10/7/2006

How can I set this list value to be the date returned frm the class?

Thanks
Jeff

Oct 27 '06 #4
Well, if you are using the DateTime object in .NET you can cast the
same object into many forms which would allow you to check for
equality. Read about the different methods in the DateTime object here

http://msdn2.microsoft.com/en-us/lib...e_methods.aspx

Hope that helps.

Jeff User wrote:
The dropdown is a list of dates. I have to find the index of the date
desired to set it as the selected item in the list. The desired value
being the date with only the 1 digit for the day, the list items being
the dates with 2 digits. I spose I can add the zero to the 1 digit day
to make it match the dropdown date format.
I was wondering if there was some way to use formating to get one to
look like the other.

Thanks

On 26 Oct 2006 10:31:09 -0700, "justin creasy"
<ju***********@gmail.comwrote:
Jeff,

Does the value have to be stored in SelectedIndex or could you
subscribe to the SelectedIndexChanged event, and when you catch the
event do the processing needed to remove the extra digit and place it
into another variable.

Jeff User wrote:
Hi all

The date values in my dropdown list appear as mm/dd/yyyy
Specifically, the day always contains 2 digits.
I need to set the selected index of the dropdown to the date that
equals another date value that does not use 2 digits for the day, if
the day is less that 10.
example
ddlBeginDate.SelectedIndex =
ddlBeginDate.Items.IndexOf(ddlBeginDate.Items.Find ByText(someClass.BeginDate.ToShortDateString()));

does not work when the list contains 10/07/2006
and the value returned by someClass.BeginDate.ToShortDateString() is
10/7/2006

How can I set this list value to be the date returned frm the class?

Thanks
Jeff
Oct 27 '06 #5
Maybe I'm not understanding something here, but why don't you handle
the dates as DateTime objects? Date objects are easily compared. If
they are already strings - coming from the selection list- cast them to
DateTime, compare, then convert back to string.
On 2006-10-26 14:21:13 -0500, Jeff User <je*******@hotmail.comsaid:
>
The dropdown is a list of dates. I have to find the index of the date
desired to set it as the selected item in the list. The desired value
being the date with only the 1 digit for the day, the list items being
the dates with 2 digits. I spose I can add the zero to the 1 digit day
to make it match the dropdown date format.
I was wondering if there was some way to use formating to get one to
look like the other.

Thanks

On 26 Oct 2006 10:31:09 -0700, "justin creasy"
<ju***********@gmail.comwrote:
>Jeff,

Does the value have to be stored in SelectedIndex or could you
subscribe to the SelectedIndexChanged event, and when you catch the
event do the processing needed to remove the extra digit and place it
into another variable.

Jeff User wrote:
>>Hi all

The date values in my dropdown list appear as mm/dd/yyyy
Specifically, the day always contains 2 digits.
I need to set the selected index of the dropdown to the date that
equals another date value that does not use 2 digits for the day, if
the day is less that 10.
example
ddlBeginDate.SelectedIndex =
ddlBeginDate.Items.IndexOf(ddlBeginDate.Items.Fi ndByText(someClass.BeginDate.ToShortDateString())) ;
does
>>>

does not work when the list contains 10/07/2006
and the value returned by someClass.BeginDate.ToShortDateString() is
10/7/2006

How can I set this list value to be the date returned frm the class?

Thanks
Jeff

Oct 27 '06 #6

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

Similar topics

1
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two...
13
by: melih.onvural | last post by:
Group, I'm having a tough time understanding some of the previous posts on this topic so I wanted to write what I've tried and hope that you can help me troubleshoot. I have a dropdown populated...
5
by: Gil | last post by:
Is there a way to tell if a combbox is in dropdown mode. I tried and if statement combobox.dropdown = true but i get an error. dropwndown function doesnt store if its true or false what i am...
3
by: CSharpguy | last post by:
I'm trying to populate a drop down with dates from a data field in my data base but I want the format like MM/dd/yyyy instead of 1/1/2006 12:00 PM How can I my date to show as 1/1/2006? I'm...
3
by: devNorway | last post by:
I have been struggling with a problem for days now, and searched for related problems and solutions but had no luck. I have two dropdown listboxes where the first is populated in page load and...
2
by: Jon Vaughan | last post by:
Hi, I was looking for a control that you enter time values into , I started off with a textbox, but then saw the datetime picker had a custom format for Time , so I entered HH:mm. The conctrol...
0
by: veerleverbr | last post by:
I'm looking for a DateTime control that works a bit like the WebDateChooser of Infragistics. This control has a mask which allows only valid dates to be entered. So no alphabetic characters...
0
by: Kay | last post by:
Hello, I have written my own custom control and I want one of its properties to display as a dropdown list when clicked, so the user can select from the list, it would be similar to the asp...
5
by: ArizonaState | last post by:
I have a situation where I need to update a table with a time retrieved from a dropdown list. CODE... cmd.SqlParameters.Add((@StartTime, SqlDataType.DateTime).Value = ...
0
by: =?Utf-8?B?a3BpenpsZQ==?= | last post by:
Hi all. using vs.net 9, C# I've got a trivial dilemma right now with my datetimepicker. It is bound to a datetime field in a database. This field is also set to not allow nulls. The default...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.