C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






How to avoid Multiple selection not allowed in DropDownList problem


Posted Date: 28 Aug 2008    Resource Type: Errors and Solutions    Category: General
Author: Raju.MMember Level: Gold    
Rating: Points: 4



The error message is that multiple section of DropDownList is not allowed.

If you face this problem just add the follwoign code:


DropDownList1.ClearSelection();
DropDownList1.Items[3].Selected=true;


This code first clear any selection of item and then selects the required item.

For more details, visit http://makhaai.blogspot.com/2008/08/avoid-dropdownlist-multiple-selection.html




Responses

Author: Prafulla S Shimpi    12 Sep 2008Member Level: Gold   Points : 1
Can you please put complete code?
This doesn't give clear idea about this code.

One thing you can try is use List box instead of Dropdown.
This may help you.

Also, tell me are you using datareader object to fill the dropdown?



Author: Raju.M    15 Sep 2008Member Level: Gold   Points : 2
if u have a dropdownlist like DropDownList3.
we can chege the SelectedIndex through code.

if (DropDownList3.Items.Count > 0)
{
for (int i = 0; i < DropDownList3.Items.Count; i++)
{
if (DropDownList3.Items[i].Text == "someType")
{
DropDownList3.Items[i].Selected == true;
break;
}
}
}


now we change this SelectedIndex to any other



if (DropDownList3.Items.Count > 0)
{
for (int i = 0; i < DropDownList3.Items.Count; i++)
{
if (DropDownList3.Items[i].Text == "Education")
{
DropDownList3.Items[i].Selected == true;
break;
}
}
}


it will produce an error "Multiple selection not allowed in DropDownList" to avoid this we cann write



if (DropDownList3.Items.Count > 0)
{
for (int i = 0; i < DropDownList3.Items.Count; i++)
{
if (DropDownList3.Items[i].Text == "Education")
{
DropDownList3.ClearSelection();
DropDownList3.Items[i].Selected == true;
break;
}
}
}



i think now u can get the clear picture.if u have more doubts reply me


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Multiple selection not allowed in DropDownList problem  .  How to avoid Multiple selection not allowed in DropDownList problem  .  Error  .  Dropdown  .  ASP.NET DropDownList  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Failed to add web part (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION)) exception
Previous Resource: Crystal Report DB Login(VB.Net)
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use