DataTextField Conversion Question

  • Thread starter Thread starter Jason Heine
  • Start date Start date
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,
 
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.
 
Back
Top