Results 1 to 5 of 5

Thread: [RESOLVED]databinding dropdown problem

  1. #1

    Thread Starter
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727

    [RESOLVED]databinding dropdown problem

    I have a dropdown that is populated through a stored procedire triggered from the chnage of a different drop down.

    I am getting the message

    Specified argument was out of the range of valid values.
    Parameter name: value

    does any know what this means so i can start to investigate, I cannot get debug working so I dont knwo where to start looking

    -----------------------------------------------

    I Have changed code too:

    Code:
    ddSectorName.SelectedIndex = 0
    
    ddSectorName.DataSource = dsSectorName
    ddSectorName.DataTextField = "SECT_NM"
    ddSectorName.DataValueField = "SECT_ID"
    ddSectorName.DataBind()
    
    ddSectorName.Items.Insert(0, "All")
    ddSectorName.Items(0).Value = "%"
    
    ddSectorName.SelectedIndex = 0
    it seems that the dropdown was stroing the indexnumber for the currently selected item in viewstate, and when databinding if the new list of items was not as big as the previous then it couldnt find the index and it would fall over.
    Last edited by davebat; Mar 10th, 2005 at 05:34 AM. Reason: [RESOLVED]

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: databinding dropdown problem

    The code to generate the dropdowns would help. HTML and C# or VB.Net script.

    DJ

  3. #3

    Thread Starter
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727

    Re: databinding dropdown problem

    Drop down change

    Code:
        Private Sub ddChannelName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddChannelName.SelectedIndexChanged
            Dim dsSectorName As New DataSet
            Dim cmpData As New dataaccess
            Dim strChannelID As String = ddChannelName.SelectedItem.Value
            dsSectorName = cmpData.getSectNm(strChannelID)
            ddSectorName.Items.Clear()
            ddSectorName.DataSource = dsSectorName
            ddSectorName.DataTextField = "SECT_NM"
            ddSectorName.DataValueField = "SECT_ID"
            ddSectorName.DataBind()
            ddSectorName.Items.Insert(0, "All")
            ddSectorName.Items(0).Value = "%"
        End Sub

  4. #4
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: databinding dropdown problem

    Instead of:
    Code:
    ddSectorName.Items.Insert(0, "All")
    ddSectorName.Items(0).Value = "%"
    Try:
    Code:
    Dim newItem As ListItem
    newItem.Text = "All"
    newItem.Value = "%"
    
    ddSectorName.Items.Insert(0, newItem)
    DJ

  5. #5

    Thread Starter
    Fanatic Member davebat's Avatar
    Join Date
    Dec 2002
    Posts
    727

    Re: databinding dropdown problem

    thanks DJ, but this didn't help. The error occurs when the event fires and ddSectorName index was not currently on 'All'.

    Any ideas, or an english translation of the error message

Posting Permissions

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



Click Here to Expand Forum to Full Width