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.GetStartingDates 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*******@discussions.microsoft.com> wrote in message
news:DC**********************************@microsof t.com...
dropdown.datasource = dataset;
should it be different?
even doing this is returning me the dateTime as 1/1/006 12:00 PM
DataSet startDate= SalesForYear.GetStartingDates();
dropDown.DataSource = asOfDate.Tables[0].DefaultView;
dropDown.DataTextField = String.Format("{0:d}", "fieldDate");
ddMonthEnd.DataValueField = String.Format("{0:d}", "fieldDate");
dropDown.DataBind();
"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*******@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.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.ToDateTime(dataset.tables[0].rows[0]["fieldDate"].toString()).ToShortDateString();
> dropdown.datatexfield = time;
> dropdown.datavaluefield = time
> dropdown.databind();
>
> DataBinder.Eval: 'System.Data.DataRowView' does not contain a property
> with
> the name 12/31/2006
>
> and it highlights this code:
> dropdown.databind();
>
> what am I missing?
>
> but i'm getting this error:
>
>