2012-06-20 6 views
0

실마리를 줄 수 있습니까? 나는 DropDownList이며, DropDownListListItems으로 채워져 있습니다. DropDownList 뒤에 ADD NEW라고하는 Button이 있습니다. 버튼을 클릭하면 팝업 창이 열립니다. 항목이 DropDownList에 없으면 추가하고 싶습니다. 팝업 상자 창에 TextBox이 있고 Button을 추가하십시오.버튼을 클릭하면 팝업 드롭 다운 목록이 열림

기본적으로 항목이 DropDownlist이 아닌 경우 ADD NEW 버튼을 클릭하여 추가하고 싶습니다.

+1

(HTTP : //mattgemmell.com/2008/12/08/what-have-you-tried/)? –

+0

@TimSchmelter 코드를 작성하려고 합니다만, 여기에서는 올바른 방향을 묻습니다. 코드가 아닙니다. – Learner

답변

1

다음 줄에 뭔가 ... 당신이 항목을 눌러 버튼을 추가 입력 팝업에서

string newItem = textbox1.Text; 
if(ddlMyList.Items.FindByText(newItem) == null) //Means item not found 
    { 
    ddlMyList.Items.Add(new ListItem(newItem)); 
    } 
1

만 할 다음 단계 :

[당신이 시도 무엇]
1. Iterate through all the elements in dropdown and check if item you want to add exist or not 
2. If item does not exist then add it to dropdown using this code: 
    yourDropdown.items.Add(newitem); 
관련 문제