473,395 Members | 1,584 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,395 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 3851
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.