...

dynamic dropdownlist

flann
09-14-2005, 03:13 PM
I'm trying to create a dynamic dropdownlist, not in a datagrid, that populates the list based off of the current month, and then the previous 11 months. I've got it working to the point that it does populate the ddl, but then it is refilling it.

Does anybody know of a good resource that shows how to do this?

Brandoe85
09-14-2005, 03:16 PM
Are you clearing your list before you populate it again? Can you post your code?

Good luck

flann
09-14-2005, 03:21 PM
Sub setDropDownList()
ddlTimeFrame.Items.Clear()
Dim monthArray() As String = {"January", "February", "March", "April", "May", "June", "July", _
"August", "September", "October", "November", "December"}
Dim testDate As Integer
Dim strMonth As String

Dim count As Integer = 0
myDate = myDate.Today()
testDate = myDate.Month()

While count < 12
testDate -= 1
strMonth = CStr(monthArray.GetValue(testDate))

ddlTimeFrame.Items.Add(strMonth)
Page.FindControl("phTimeFrame").Controls.Add(ddlTimeFrame)
If testDate = 0 Then
testDate = 12
End If
count += 1
End While
End Sub

I added the ddlTimeFrame.Items.Clear() but it is still refilling it

rrhodes
09-15-2005, 03:23 PM
Are you calling this funtion inside or outside an

if (not IsPostback) then

end if

constructor?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum