469,890 Members | 1,432 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,890 developers. It's quick & easy.

ERROR: Cannot have multiple items selected in a DropDownList.

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
Jun 25 '07 #1
2 14936
On Jun 25, 4:46 pm, Krishna <Kris...@discussions.microsoft.comwrote:
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/
Jun 25 '07 #2
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" <Kr*****@discussions.microsoft.comwrote in message
news:3F**********************************@microsof t.com...
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

Jun 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by bill yeager | last post: by
1 post views Thread by Aaron Prohaska | last post: by
1 post views Thread by John Ninan | last post: by
2 posts views Thread by dhnriverside | last post: by
5 posts views Thread by tshad | last post: by
1 post views Thread by Kevin Blount | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.