Click here to Skip to main content
15,915,734 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi to all,

i need to create drop-down list in asp.net with items, which display all items but some of them disable for select.


e.g
C#
public void fillDrp()
   {
       drp1.Items.Clear();
       drp1.Items.Add(new ListItem("a", "1", true));
       drp1.Items.Add(new ListItem("b", "2", true));
       drp1.Items.Add(new ListItem("c", "3", false));
       drp1.Items.Add(new ListItem("d", "4", true));
   }


this code is hiding the item "c", while i need to show this item in to list but make disable for selection.

Thanks in advance... :)
--Amit
Posted

hi friend

for this type we should write a javascript like


function change()
{
var dd=document.getElementById ("<%=DropDownList1.ClientID %>;');
var value=dd.options[dd.selectedIndex].value;
if(value!=your disabled index)
{
do what you want
}
}
 
Share this answer
 
I am pretty much certain that what you want is impossible using HTML, which means it's impossible in ASP.NET. The best you can do, is to write javascript that detects when something in your blacklist is selected, and unselected it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900