|
 |
aspx_beginners thread: Matching date values w/ dropdown values
Message #1 by "Joseph Janick" <joseph_janick@u...> on Wed, 26 Feb 2003 18:25:22
|
|
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
How can this be corrected?
Message #2 by "Peter Lanoie" <planoie@n...> on Wed, 26 Feb 2003 14:00:45 -0500
|
|
Can you clarify the description?
A) How are you populating the list box?
1. Databinding
2. Loop with ddl.Add()
3. Something else?
B) What do you mean by "Based on a selection in a listbox, the ddl's show
date info for the selection based on a SQL SELECT ...". I'm not quite clear
what you mean by this.
C) Can you post some code relevant to the problem?
-----Original Message-----
From: Joseph Janick [mailto:joseph_janick@u...]
Sent: Wednesday, February 26, 2003 18:25
To: aspx_beginners
Subject: [aspx_beginners] Matching date values w/ dropdown values
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
How can this be corrected?
Message #3 by "Joseph Janick" <joseph_janick@u...> on Thu, 27 Feb 2003 16:09:56
|
|
Will do, Peter.
A. I'm using #2.
B. When my SELECT statement returns results, it fills the ddl's at the
line above the values I had hard coded on the .aspx page, as in the
example earlier. I used the 'FindByValue' method for 2 other ddl's and it
works fine, but not for the ddl's with dates.
C. Here's the code I have so far:
Public Sub lstMemos_Changed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles lstMemos.SelectedIndexChanged
lblMessage.Text = ""
Dim objSQLListPick As New SQLComponent()
objSQLListPick.strConnection = objConstants.DBConnectionString_Umove
objSQLListPick.strSQL = "SELECT * FROM umv_memoManagement,
umv_userList WHERE usr_pk = mgt_forWhatMemberInGroup ORDER BY mgt_memoURL
ASC"
objSQLListPick.ExecuteSqlStatementAndReturnResults()
Dim objMemo As ListItem
If lstMemos.SelectedIndex > -1 And txtWhatObjectGetsFocus.Text
= "lnkEdit" Then
For Each objMemo In lstMemos.Items
If objMemo.Selected = True Then
Dim intTheSelectedIndex As Integer = lstMemos.SelectedIndex
txtDescrip.Text = Trim(objSQLListPick.returnDataViewValue
(intTheSelectedIndex)("mgt_memoDescription").ToString())
ddlGroup.SelectedIndex = ddlGroup.Items.IndexOf
(ddlGroup.Items.FindByValue(Trim(objSQLListPick.returnDataViewValue
(intTheSelectedIndex)("mgt_forWhatGroup").ToString())))
If ddlGroup.SelectedIndex = 1 Then
ddlMember.SelectedItem.Text = ""
ElseIf ddlGroup.SelectedIndex = 2 Then
ddlMember.SelectedItem.Text = Trim
(objSQLListPick.returnDataViewValue(intTheSelectedIndex)
("usr_department").ToString())
Else
ddlMember.SelectedItem.Text = Trim
(objSQLListPick.returnDataViewValue(intTheSelectedIndex)
("usr_firstName").ToString()) & " " & Trim
(objSQLListPick.returnDataViewValue(intTheSelectedIndex)
("usr_lastName").ToString())
End If
Dim dateInfo As New System.Globalization.DateTimeFormatInfo
()
Dim myDate As DateTime = Trim
(objSQLListPick.returnDataViewValue(intTheSelectedIndex)
("mgt_effectiveStartDate").ToString())
ddlMonth.SelectedItem.Text = dateInfo.GetMonthName
(myDate.Month)
ddlDay.SelectedItem.Text = myDate.Day
ddlYear.SelectedItem.Text = myDate.Year
Dim myDate2 As DateTime = Trim
(objSQLListPick.returnDataViewValue(intTheSelectedIndex)
("mgt_effectiveEndDate").ToString())
ddlMonth2.SelectedItem.Text = dateInfo.GetMonthName
(myDate2.Month)
ddlDay2.SelectedItem.Text = myDate2.Day
ddlYear2.SelectedItem.Text = myDate2.Year
txtWhatObjectGetsFocus.Text = "lnkEdit"
End If
Next
Else
txtDescrip.Text = ""
ddlGroup.SelectedItem.Text = "Choose..."
ddlMember.SelectedItem.Text = "Choose..."
End If
End Sub
ddlMonth, ddlDay, ddlYear, ddlMonth2, ddlDay2, and ddlYear2 are the
controls I'm trying to get to work.
> Can you clarify the description?
A) How are you populating the list box?
1. Databinding
2. Loop with ddl.Add()
3. Something else?
B) What do you mean by "Based on a selection in a listbox, the ddl's show
date info for the selection based on a SQL SELECT ...". I'm not quite
clear what you mean by this.
C) Can you post some code relevant to the problem?
|
|
 |