Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

ERROR: Cannot have multiple items selected in a DropDownList.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Krishna - 25 Jun 2007 11:46 GMT
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
Masudur - 25 Jun 2007 12:16 GMT
> Hi,
>    I am devloping one web application using .net framework 2.0.One page has
[quoted text clipped - 18 lines]
> 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/
Eliyahu Goldin - 25 Jun 2007 13:18 GMT
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.

Signature

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

> Hi,
>   I am devloping one web application using .net framework 2.0.One page has
[quoted text clipped - 18 lines]
> Thanks and Regards
> T.A.Krishna

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.