473,657 Members | 2,896 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DateTime in dropdown

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.ToDateT ime(dataset.tab les[0].rows[0]["fieldDate"].toString()).To ShortDateString ();
dropdown.datate xfield = time;
dropdown.datava luefield = time
dropdown.databi nd();

DataBinder.Eval : 'System.Data.Da taRowView' does not contain a property with
the name 12/31/2006

and it highlights this code:
dropdown.databi nd();

what am I missing?

but i'm getting this error:
Apr 13 '06 #1
3 1984
What is the DataSource for the dropdownlist ?

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics. com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"CSharpguy" <CS*******@disc ussions.microso ft.com> wrote in message
news:C4******** *************** ***********@mic rosoft.com...
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.ToDateT ime(dataset.tab les[0].rows[0]["fieldDate"].toString()).To ShortDateString ();
dropdown.datate xfield = time;
dropdown.datava luefield = time
dropdown.databi nd();

DataBinder.Eval : 'System.Data.Da taRowView' does not contain a property
with
the name 12/31/2006

and it highlights this code:
dropdown.databi nd();

what am I missing?

but i'm getting this error:

Apr 13 '06 #2
dropdown.dataso urce = dataset;
should it be different?
even doing this is returning me the dateTime as 1/1/006 12:00 PM

DataSet startDate= SalesForYear.Ge tStartingDates( );
dropDown.DataSo urce = asOfDate.Tables[0].DefaultView;
dropDown.DataTe xtField = String.Format(" {0:d}", "fieldDate" );
ddMonthEnd.Data ValueField = String.Format(" {0:d}", "fieldDate" );
dropDown.DataBi nd();
"Swanand Mokashi" wrote:
What is the DataSource for the dropdownlist ?

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics. com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"CSharpguy" <CS*******@disc ussions.microso ft.com> wrote in message
news:C4******** *************** ***********@mic rosoft.com...
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.ToDateT ime(dataset.tab les[0].rows[0]["fieldDate"].toString()).To ShortDateString ();
dropdown.datate xfield = time;
dropdown.datava luefield = time
dropdown.databi nd();

DataBinder.Eval : 'System.Data.Da taRowView' does not contain a property
with
the name 12/31/2006

and it highlights this code:
dropdown.databi nd();

what am I missing?

but i'm getting this error:


Apr 13 '06 #3
You can not use the formatting function when specifying teh DataTextField or
DataValueField. What is happening is if the date is 1/1/006 12:00 PM, the
DataTextField is "1/1/2006" -- there is no such field in your dataset. Hence
the error.

You can either format the date when you are getting the data (as in
SalesForYear.Ge tStartingDates method) or use the DataBinding event of the
dropdownlist.
--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics. com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services

"CSharpguy" <CS*******@disc ussions.microso ft.com> wrote in message
news:DC******** *************** ***********@mic rosoft.com...
dropdown.dataso urce = dataset;
should it be different?
even doing this is returning me the dateTime as 1/1/006 12:00 PM

DataSet startDate= SalesForYear.Ge tStartingDates( );
dropDown.DataSo urce = asOfDate.Tables[0].DefaultView;
dropDown.DataTe xtField = String.Format(" {0:d}", "fieldDate" );
ddMonthEnd.Data ValueField = String.Format(" {0:d}", "fieldDate" );
dropDown.DataBi nd();
"Swanand Mokashi" wrote:
What is the DataSource for the dropdownlist ?

--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics. com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
"CSharpguy" <CS*******@disc ussions.microso ft.com> wrote in message
news:C4******** *************** ***********@mic rosoft.com...
> 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.ToDateT ime(dataset.tab les[0].rows[0]["fieldDate"].toString()).To ShortDateString ();
> dropdown.datate xfield = time;
> dropdown.datava luefield = time
> dropdown.databi nd();
>
> DataBinder.Eval : 'System.Data.Da taRowView' does not contain a property
> with
> the name 12/31/2006
>
> and it highlights this code:
> dropdown.databi nd();
>
> what am I missing?
>
> but i'm getting this error:
>
>


Apr 13 '06 #4

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

Similar topics

1
8281
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
2863
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
10286
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
4421
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
1621
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
1283
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...
5
3887
by: Jeff User | last post by:
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.FindByText(someClass.BeginDate.ToShortDateString()));
5
2436
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
2184
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
8384
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
8302
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
8718
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
8499
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
8601
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7314
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4150
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
2726
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
1937
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.