Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display the most current date in label.text

Status
Not open for further replies.

taree

Technical User
May 31, 2008
316
US
I have a last_Plan_Purchase_Date column in my dataset and I would like to display the last purchased date in lblDate.text. I am wondering how I can display the most current date. As you can see in the below code it always pick the first row eventhough it is not the most current date. please help

lblDate.Text = dsPhlList.Tables("phldetail").Rows(0).Item("Last_Plan_Purchased_Date").ToString()
 
Yes, with that code you will always get the firt row. Look at the datatable.Select() method. There are a few overloads. What you will have to do is sort the datatable, by date descending, then get the first row.
 
jbenson001 for your suggestion. I thought about that too but I have a dropdown selection for the users to sort by. I am afraid this will not work if the user sort it by a different field name other than purchased date.
 
so, first sort the way you need to get the correct value. then you can change the sort when the user selects from the drop down.
 
I will try that. than you for the tip.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top