2010-08-10 3 views
0

테이블 셀에 RadioButtonList이 있습니다. 각 항목을 선택하면 SelectedIndexChanged 이벤트가 발생하여 앱이 관련 목록 상자를 채울 수 있습니다. 문제는 그것이 작동을 멈췄다는 것입니다. 이제 첫 번째 항목 인 'Division'을 선택하면 이벤트가 실행되지 않습니다. 이벤트 처리기에 중단 점을 넣었고 다른 항목은 호출되지만 Division은 호출되지 않습니다. 다른 코드가 간섭하는 경우 나는 그것을 믿을 것입니다, 나는 어디서부터 시작해야할지 모르겠습니다.RadioButtonList의 항목이 실행되지 않음 SelectedIndexChanged

[업데이트] 작동하지 않는 것은 항목 # 2를 선택하면 업데이트가 작동 함을 의미합니다. 항목 # 1을 선택하면 그렇지 않습니다. 'Division'항목이 목록에 나타나는 위치를 변경하면 여전히 문제가 있습니다. 페이지로드 사이클에 이벤트 처리 체인을 중단시킬 수있는 무언가가 있습니까?

private TableCell foo()  
{ 
hierarchyLevel = new RadioButtonList(); 

ListItem DivisionItem = new ListItem(); 
DivisionItem.Text = "Division"; 
DivisionItem.Value = "afe_dvsn";   
hierarchyLevel.Items.Add(DivisionItem); 

ListItem DistrictItem = new ListItem(); 
DistrictItem.Text = "District"; 
DistrictItem.Value = "afe_dist"; 
hierarchyLevel.Items.Add(DistrictItem); 

ListItem AreaItem = new ListItem(); 
AreaItem.Text = "Area"; 
AreaItem.Value = "afe_supt"; 
hierarchyLevel.Items.Add(AreaItem); 

ListItem ForemanItem = new ListItem(); 
ForemanItem.Text = "Foreman"; 
ForemanItem.Value = "afe_frmn"; 
hierarchyLevel.Items.Add(ForemanItem); 

ListItem AfeCodeItem = new ListItem(); 
AfeCodeItem.Text = "AFE Code"; 
AfeCodeItem.Value = "afe_code"; 
hierarchyLevel.Items.Add(AfeCodeItem); 

ListItem PropertyItem = new ListItem(); 
PropertyItem.Text = "Property"; 
PropertyItem.Value = "prop_sub"; 
hierarchyLevel.Items.Add(PropertyItem); 

TableCell cellforHierarchyLevel = new TableCell(); 
cellforHierarchyLevel.ID = "hierarchyLevel"; 
cellforHierarchyLevel.Controls.Add(hierarchyLevel); 

hierarchyLevel.EnableViewState = true; 

hierarchyLevel.AutoPostBack = true; 

hierarchyLevel.SelectedIndexChanged += new EventHandler(hierarchyLevel_SelectedIndexChanged); 

return cellforHierarchyLevel; 
} 

답변

0

을 CreateChildControls에서 자동으로 던져지는 예외가 있었다(). 이로 인해 이벤트 처리기에 대한 호출이 중단되어 이벤트 처리기가 호출되지 않는 것처럼 보였습니다. 예외가 수정되면 이벤트가 정상적으로 처리됩니다.

0

그것의 아마 기본 SelectedIndex은 0 그래서 첫 번째 라디오 버튼을 선택하여 SelectedIndex 실제로 (인덱스 0 될 첫 번째 라디오 버튼 이후) 변경되지 않습니다 때문이다.

그냥 수행하여 프로그램 첫 번째 라디오 버튼을 선택할 수 있습니다

당신이 목록에 라디오 버튼을 추가 한 후
rbcohortList.SelectedIndex = 0; 

.

+0

첫 번째 것 이외의 ListItem 중 하나를 선택한 값으로 설정하면이 사실을 입증 할 수 있습니다. 그런 다음 목록에서 첫 번째 항목을 선택하면 변경 이벤트가 발생합니다. 페이지가 처음로드 될 때 라디오 버튼이 선택되지 않은 경우 변경 이벤트가 발생하지 않는 이유는 알 수 없습니다 ... – Jeremy

+0

기본 SelectedIndex가 제공되지 않는다는 사실은 첫 번째 옵션이 선택한 이벤트는 실제로 인덱스가 변경되지 않았기 때문에 발생하지 않습니다. – SwDevMan81

0

첫 번째 항목을 선택하지 않고 그 다음에 Division 항목을 선택하면 작동합니까? 당신이 마지막 항목을 추가 한 후 -1SelectedIndex를 설정하는

시도가 (즉 TableCell cellforHierarchyLevel = new TableCell(); 라인 전)

관련 문제