2013/03/29

HttpException (0x80004005): Cannot have multiple items selected in a DropDownList

HttpException (0x80004005): Cannot have multiple items selected in a DropDownList
Exception message: DropDownList에서 여러 항목을 선택할 수 없습니다.

 

DropDownList 의 Item에  중복 항목이 있고,
SelectedValue 등에 의해서 중복값이 선택되는 경우.

<asp:ListItem>same</asp:ListItem>
<asp:ListItem>same</asp:ListItem>

DropDownList.SelectedValue = "same";

또는,

ListItem  개체를 하나 생성후에,
2개 이상의 DropDownList 컨트롤에 Item 개체로 추가하는 경우 처음 호출한 DropDownList  의 SelectedValue 후 다른 DropDownList 컨트롤에서 다시 SelectedValue  하는 경우에 원본 ListItem 개체 참조 때문.

DropDownList.Items.Add(new ListItem("text", "value")); 와 같이 하거나
원본 ListItem 을 각 컨트롤용으로 개별 생성.

 

 

 


댓글 없음:

댓글 쓰기

가장 많이 본 글