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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matching date values w/ dropdown values

Status
Not open for further replies.

JoeCool32

Programmer
Sep 26, 2002
50
0
0
US
In my program, I have 6 ddl's filled programatically with date info (month, day & year) in my client-side code. Based on a selection in a listbox, the ddl's show date info for the selection based on a SQL SELECT statement in my (VB) server-side code; the problem is the date parts returned had no value. I wanted to match what was returned with values I had put in the dropdowns programatically. For example, if the day from SQL was the 3rd, I'd want it to show up in the list at the 3 that I've inserted on client-side, like so:

1
2
3 <--
4
5

Right now it comes up like this:

3 <--
1
2
3
4
5
[sadeyes]
How can this be corrected? JJ [peace]

&quot;Ignorance and prejudice and fear walk hand in hand&quot; - Witch Hunt, by Rush
 
Note: I had been trying to use FindByValue and/or FindByText on these; they had worked on my other ddl's in the program, but not these.

The key parts of the code are like so:

Code:
Dim dateInfo As New System.Globalization.DateTimeFormatInfo()
Dim myDate As DateTime = Trim(objSQLMemoList.returnDataViewValue(intTheSelectedIndex)(&quot;mgt_effectiveStartDate&quot;).ToString())

ddlMonth.SelectedItem.Text = dateInfo.GetMonthName(myDate.Month)
ddlDay.SelectedItem.Text = myDate.Day
ddlYear.SelectedItem.Text = myDate.Year

Dim myDate2 As DateTime = Trim(objSQLMemoList.returnDataViewValue(intTheSelectedIndex)(&quot;mgt_effectiveEndDate&quot;).ToString())

ddlMonth2.SelectedItem.Text = dateInfo.GetMonthName(myDate2.Month)
ddlDay2.SelectedItem.Text = myDate2.Day
ddlYear2.SelectedItem.Text = myDate2.Year

Apparently people in other forums didn't understand what I was saying[dazed], so I'm trying to clear things up here. JJ [peace]

&quot;Ignorance and prejudice and fear walk hand in hand&quot; - Witch Hunt, by Rush
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top