473,806 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Se lectedIndex =
ddlBeginDate.It ems.IndexOf(ddl BeginDate.Items .FindByText(som eClass.BeginDat e.ToShortDateSt ring()));

does not work when the list contains 10/07/2006
and the value returned by someClass.Begin Date.ToShortDat eString() 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 3918
Jeff,

Does the value have to be stored in SelectedIndex or could you
subscribe to the SelectedIndexCh anged 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.Se lectedIndex =
ddlBeginDate.It ems.IndexOf(ddl BeginDate.Items .FindByText(som eClass.BeginDat e.ToShortDateSt ring()));

does not work when the list contains 10/07/2006
and the value returned by someClass.Begin Date.ToShortDat eString() 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 SelectedIndexCh anged 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.S electedIndex =
ddlBeginDate.I tems.IndexOf(dd lBeginDate.Item s.FindByText(so meClass.BeginDa te.ToShortDateS tring()));

does not work when the list contains 10/07/2006
and the value returned by someClass.Begin Date.ToShortDat eString() 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*******@hotm ail.comwrote in message
news:fd******** *************** *********@4ax.c om...
>
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 SelectedIndexCh anged 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
Specificall y, 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(d dlBeginDate.Ite ms.FindByText(s omeClass.BeginD ate.ToShortDate String()));

does not work when the list contains 10/07/2006
and the value returned by someClass.Begin Date.ToShortDat eString() 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 SelectedIndexCh anged 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.Se lectedIndex =
ddlBeginDate.It ems.IndexOf(ddl BeginDate.Items .FindByText(som eClass.BeginDat e.ToShortDateSt ring()));

does not work when the list contains 10/07/2006
and the value returned by someClass.Begin Date.ToShortDat eString() 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*******@hotm ail.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 SelectedIndexCh anged 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
Specificall y, 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(d dlBeginDate.Ite ms.FindByText(s omeClass.BeginD ate.ToShortDate String()));
does
>>>

does not work when the list contains 10/07/2006
and the value returned by someClass.Begin Date.ToShortDat eString() 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
8295
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 dropdown lists. If you change the selection of the left one (e.g. choose parentoption2), it should open up page2.htm in a popup window.
13
2877
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 from a table and I want to take that selection and use it to populate the next dropdown. So far: 1) I tried using a query that said select specificissue from specific_issue and used as my criterion !!
5
10298
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 trying to do is make an autoscroll combobox. like you have on html textbox's, but this time you hit enter for a change to be made. i do this because i dont want to requery every time a single letter is inputed. it would be too slow. so i make them hit...
3
1994
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 populating the dropdown via a dataset and doing a: string time = Convert.ToDateTime(dataset.tables.rows.toString()).ToShortDateString(); dropdown.datatexfield = time; dropdown.datavaluefield = time dropdown.databind();
3
4430
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 the second is populated based on the input in the first. The first dropdown is inside a "If Not Page.IsPostBackThey" if loop. Both have autopostback set to true. The problem is that when the user makes a choice in the first dropdown an event is...
2
1627
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 does show time in the box , but in HH:mm:ss, I would like to drop the ss, also I dont want the user to beable to click the dropdown to select the date. Im looking purely for a time entry. Is this the right control and if not is there a better...
0
1291
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 allowed, only numbers. And no invalid dates like 32/01/2006 (belgian format for 32nd januari 2006). No date-pick feature with popup or dropdown or something like that is needed. Just a mask and the ability to only fill in correct dates. The problem...
0
1353
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 textbox control which has a ‘TextMode’ property and when clicked on, displays as a dropdown list with 3 values, I want to have a similar type property with a dropdown style. So far, I have a property defined which displays the dropdown arrow...
5
2448
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 = CDate(DropDownList.SelectedItem.Text) CODE/ While it does update the tabel row with a portion of the data (for ex.. 9/28/2007 12:00:00). I don't need the date part of the data, because all I am interested in is the time. So when the time in the dropdownlist is...
0
2188
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 value of this field is: getdate() My Picker's properties:
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10618
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10371
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.