2010-07-19 5 views
0

나는 dropdwonlsit (page_load 이벤트에로드 됨)이며 언 바운드 CheckBoxList는 DropDownlist의 선택 사항을 기반으로하며 checkboxList는 CheckBox (1 또는 2 또는 3 또는 숫자 일 수 있음)입니다. 페이지가 브라우저에로드되고 사용자가 확인란을 클릭 한 후 알면, 사용자가 선택한 체크 상자를 알 수있는 방법이 필요합니다. 그 일을하는 가장 좋은 방법은 무엇입니까? 지금까지 나는이 함께 올라와있다 ...점검 대상을 결정하는 방법은 무엇입니까?

<asp:CheckBoxList AutoPostBack="true" ID="chkbox" runat="server" RepeatColumns="2"  RepeatDirection="Horizontal" RepeatLayout="Table"> 
         </asp:CheckBoxList> 

    Private Sub chk_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chk.SelectedIndexChanged 


     Dim roleCollections As New RoleCollections() 
     Dim roleNames As New RoleNames() 

     Dim list As New List(Of String)() 

     For Each li As ListItem In chk.Items 
      'If li.Selected Then 
       'list.Add(li.Value) 
      'End If 
     Next 

답변

0
For Each checkBoxItem as CheckBoxItem in chkItems 
if checkBoxItem.Checked=true then 
    list.add(chckboxItem.Value) 
end if 
Next 

대신이 시도 :

: 여기

For i=0 to chkItems.Items.Coult-1 
if chkItems.Items(i).Selected then 
    list.add(chkItems.Items(i).Text) 
end if 
next 

이 vb.net 또는 C#의 예와 링크입니다 http://authors.aspalliance.com/aspxtreme/aspnet/syntax/checkboxlistwebcontrol.aspx

+0

그것은 말합니다 : CheckBoxItem가 정의되지 않았습니다 –

+0

가 작동하지 않습니다, 그 chec ked 상자. 사실 나는 하나의 체크 박스를 체크한다. 또한 autopostback = true .... –

+0

내가이 체크 박스를 체크 한 것을 업데이트하는 체크 박스를 클릭하면 어떻게됩니까? 샘플 양식 링크를 사용해 보았지만 체크하지 않았다. –

관련 문제