DataTextField Conversion Question

J

Jason Heine

Hello,
I am have a web service which I pull a dataTable and then fill a
listBox with the information.

On the ListBox1.DataTextField = "myColumn";

I need to attempt the following:

DateTime myColumn = new DateTime;

myColumn = myService.returnDataTableFunction;

ListBox1.DataSource = myService.ReturnDataTableFunction;
ListBox1.DataTextField = myColumn.ToShortDateString();

I am not getting the text value of the dataTable. My SQL Statement is as
follows:

Select top 5 week from myTable order by week desc.

I am not sure what I am missing. Any advise would help.

Thanks,
 
N

Nicholas Paldino [.NET/C# MVP]

Jason,

The way you are setting the DataTextField is incorrect. You want to set
this property to the name of the field in the table that contains the value
you want to display.

Hope this helps.
 

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

Top