DataBinding: 'System.Data.DataRowView' does not contain a property with the name

J

John

I'm getting this error when i'm trying to databind my dataset to a dropdown:
DataBinding: 'System.Data.DataRowView' does not contain a property with the
name '12/12/2003'
but if I do a response.write I can see the dates fine, what is causing this
error?

code:
dYear.DataSource = dsYearofSales.Tables[1];
string strYearofSales = dsYearofSales[1].Rows[0]["SaleDate"].tostring();
dYear.DataTextField =
Convert.ToDateTime(strYearofSales).ToShortDateString();
dYear.DataValueField =
Convert.ToDateTime(strYearofSales).ToShortDateString();

but if i do
Response.write(Convert.ToDateTime(strYearofSales).ToShortDateString());
it works, so what am i missing or doing wrong?
 
J

John

yeah i know, but I want to conver it to a 12/12/2003 and not 12/12/2003
12:00 AM
as the below code does.
I've used the below code and it works but I want the date as 12/12/2003 and
not 12/12/2003 12:00 AM.

the Convert.ToDateTime() is causing my issue
Eliyahu Goldin said:
All you need is:

dYear.DataSource = dsYearofSales.Tables[1];
dYear.DataTextField ="SaleDate";
dYear.DataBind();

Welcome to asp.net from asp!

Eliyahu

John said:
I'm getting this error when i'm trying to databind my dataset to a
dropdown:
DataBinding: 'System.Data.DataRowView' does not contain a property with
the name '12/12/2003'
but if I do a response.write I can see the dates fine, what is causing
this error?

code:
dYear.DataSource = dsYearofSales.Tables[1];
string strYearofSales = dsYearofSales[1].Rows[0]["SaleDate"].tostring();
dYear.DataTextField =
Convert.ToDateTime(strYearofSales).ToShortDateString();
dYear.DataValueField =
Convert.ToDateTime(strYearofSales).ToShortDateString();

but if i do
Response.write(Convert.ToDateTime(strYearofSales).ToShortDateString());
it works, so what am i missing or doing wrong?
 
E

Eliyahu Goldin

All you need is:

dYear.DataSource = dsYearofSales.Tables[1];
dYear.DataTextField ="SaleDate";
dYear.DataBind();

Welcome to asp.net from asp!

Eliyahu
 
E

Eliyahu Goldin

Then loop through the items of dYear after data binding and re-format their
text by with your converting calls.

Eliyahu

John said:
yeah i know, but I want to conver it to a 12/12/2003 and not 12/12/2003
12:00 AM
as the below code does.
I've used the below code and it works but I want the date as 12/12/2003
and not 12/12/2003 12:00 AM.

the Convert.ToDateTime() is causing my issue
Eliyahu Goldin said:
All you need is:

dYear.DataSource = dsYearofSales.Tables[1];
dYear.DataTextField ="SaleDate";
dYear.DataBind();

Welcome to asp.net from asp!

Eliyahu

John said:
I'm getting this error when i'm trying to databind my dataset to a
dropdown:
DataBinding: 'System.Data.DataRowView' does not contain a property with
the name '12/12/2003'
but if I do a response.write I can see the dates fine, what is causing
this error?

code:
dYear.DataSource = dsYearofSales.Tables[1];
string strYearofSales = dsYearofSales[1].Rows[0]["SaleDate"].tostring();
dYear.DataTextField =
Convert.ToDateTime(strYearofSales).ToShortDateString();
dYear.DataValueField =
Convert.ToDateTime(strYearofSales).ToShortDateString();

but if i do
Response.write(Convert.ToDateTime(strYearofSales).ToShortDateString());
it works, so what am i missing or doing wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top