Share via

sort static dropdown using VB.NET asp.net page

TheCoder 91 Reputation points
2022-06-16T12:12:13.49+00:00

I'm populating a dropdown with dates, it's currently showing the dates as

8/1/2022
7/1/2022
6/1/2022
5/1/2022

I want to show the dates as
5/1/2022
6/1/2022
7/1/2022
8/1/2022

protected sub getDates(sender as Object, e as EventArgs)  
dim ddDates as New List(of ListItems)  
for i = 1 to 4  
  beginDate = beginDate.AddMonths(-1)  
  ' formats the dates here from variables creating the dates  
next  
with reportDropDown  
   .DataTextField = "text"  
   .DataValueField = "Value"  
   .DataBind()  
end with  
  
  
end sub  
Developer technologies | VB
Developer technologies | ASP.NET Core | Other
0 comments No comments

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 84,086 Reputation points
    2022-06-16T19:17:22.233+00:00

    just use

    ddDates.Insert(0, value)

    rather than add

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.