This project is read-only.

Lockdown drop down lists on new_ticket.aspx

Apr 12, 2011 at 10:43 AM

Hi again.

 I've got another question.

 I'm trying to insert this code in new_ticket.aspx:

                ddlUnit.Items.FindByText("Skole-IT").Selected = true; 

Just below this code:

                foreach (unit u in units.OrderBy(p => p.unit_name))
                    ddlUnit.Items.Add(new ListItem(u.unit_name,;
                Utils.PopulateSubUnits(db, ddlUnit, ddlSubUnit, accessLevel);

I have a group called "Skole-IT" and I want this group to be preselected when a user creates a new ticket, but I get an error:

"Cannot have multiple items selected in a DropDownList."


I can't figure out where this error comes from, since the debugger gives me a line number in the aspx file, where the drop down list is specified.

Can anyone help me out?


Thanks in advance.


Kind regards


Apr 12, 2011 at 3:53 PM

since you are setting: ddlUnit.Items.FindByText("Skole-IT").Selected = true; - and apparently the .Selected was already set to true for another element, which you cannot have two.  If you can't pinpoint where the selection is being made - you could run through all the elements in the list, set the selected = false, then set it again.  This wouldn't be the most efficient, but it would work until you could figure out the proper place to make the change.

Apr 14, 2011 at 12:49 PM



I would really appreciate if you or someone else could give me a hint to set all drop down items select mode to false. I can't figure it out, but I'm also very green when it comes to c# programming.

Thanks in advance.

Kind regards


Apr 15, 2011 at 11:47 AM

Fixed my self, by modding the code to the following:



foreach (unit u in units.OrderBy(p => p.unit_name))



new ListItem(u.unit_name,;



"Skole-IT").Selected = true;