Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dynamic dropdownlist

    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?

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Are you clearing your list before you populate it again? Can you post your code?

    Good luck

  • #3
    New Coder
    Join Date
    Aug 2005
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    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
    Last edited by flann; 09-14-2005 at 03:30 PM.

  • #4
    New Coder
    Join Date
    Aug 2005
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you calling this funtion inside or outside an

    if (not IsPostback) then

    end if

    constructor?
    Robert
    Gee! Web Tools
    Web Content Management / Internet Marketing modules including:
    Page Editor - Calendar Manager - News Editor - Contact Organizer - Mail Wizard


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •