ERROR: Cannot have multiple items selected in a DropDownList.

Discussion in 'ASP .Net' started by =?Utf-8?B?S3Jpc2huYQ==?=, Jun 25, 2007.

  1. Hi,
    I am devloping one web application using .net framework 2.0.One page has
    7 dropdown list control.When i update the values first bind the values to
    the drop down llist then selected text using findbytext method.I got the
    following error

    ERROR: Cannot have multiple items selected in a DropDownList.

    Coding is below

    Me.ddlMaterial.DataSource = ds
    Me.ddlMaterial.DataTextField = "Material
    Me.ddlMaterial.DataTextField = "Material
    Me.ddlMaterial.DataBind()
    Dim Material As String = row("Material").ToString()
    Me.ddlMaterial.ClearSelection()
    Me.ddlMaterial.Items.FindByText(Material).Selected = True
    how to solve the issue?
    pls help.

    Thanks and Regards
    T.A.Krishna
     
    =?Utf-8?B?S3Jpc2huYQ==?=, Jun 25, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?S3Jpc2huYQ==?=

    Masudur Guest

    On Jun 25, 4:46 pm, Krishna <> wrote:
    > Hi,
    > I am devloping one web application using .net framework 2.0.One page has
    > 7 dropdown list control.When i update the values first bind the values to
    > the drop down llist then selected text using findbytext method.I got the
    > following error
    >
    > ERROR: Cannot have multiple items selected in a DropDownList.
    >
    > Coding is below
    >
    > Me.ddlMaterial.DataSource = ds
    > Me.ddlMaterial.DataTextField = "Material
    > Me.ddlMaterial.DataTextField = "Material
    > Me.ddlMaterial.DataBind()
    > Dim Material As String = row("Material").ToString()
    > Me.ddlMaterial.ClearSelection()
    > Me.ddlMaterial.Items.FindByText(Material).Selected = True
    > how to solve the issue?
    > pls help.
    >
    > Thanks and Regards
    > T.A.Krishna


    okay....

    please check wheither you are selecting the same dropdown's items more
    than once...

    i had suffered from this problem in one of my asp.net 1.1 project...
    but as for me my problem happend with htmldropdown

    private void ClearSelection(HtmlSelect ddl)
    {
    foreach(ListItem item in ddl.Items)
    {
    item.Selected = false;
    }
    }

    this function saved me that time...
    each time i tried to select a new value i called this method before
    selecting new value...
    as htmlSelect does not have clearSelection Method...

    Thanks
    Masudur
    http://munnacs.110mb.com/
     
    Masudur, Jun 25, 2007
    #2
    1. Advertising

  3. Make sure you are not databinding multiple ddls to the same datasource.
    Being selected is an attribute of an item, therefore, if different ddls
    select different items from the same datasource, each of the ddls ends up
    with multiple items selected which is exactly what you are observing.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Krishna" <> wrote in message
    news:...
    > Hi,
    > I am devloping one web application using .net framework 2.0.One page has
    > 7 dropdown list control.When i update the values first bind the values to
    > the drop down llist then selected text using findbytext method.I got the
    > following error
    >
    > ERROR: Cannot have multiple items selected in a DropDownList.
    >
    > Coding is below
    >
    > Me.ddlMaterial.DataSource = ds
    > Me.ddlMaterial.DataTextField = "Material
    > Me.ddlMaterial.DataTextField = "Material
    > Me.ddlMaterial.DataBind()
    > Dim Material As String = row("Material").ToString()
    > Me.ddlMaterial.ClearSelection()
    > Me.ddlMaterial.Items.FindByText(Material).Selected = True
    > how to solve the issue?
    > pls help.
    >
    > Thanks and Regards
    > T.A.Krishna
     
    Eliyahu Goldin, Jun 25, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Tolman
    Replies:
    1
    Views:
    7,851
    Jim Cheshire [MSFT]
    Jan 7, 2004
  2. Tom Bray
    Replies:
    2
    Views:
    2,138
    JeffSchumacher
    Apr 13, 2005
  3. DC Gringo
    Replies:
    1
    Views:
    2,482
    Karl Seguin
    Jul 26, 2005
  4. Iain
    Replies:
    3
    Views:
    951
  5. Vi
    Replies:
    11
    Views:
    359
    Adam S
    Dec 20, 2006
Loading...

Share This Page