2013-09-23 2 views
1

radiobuttonlist는 어떻게 찾을 수 있으며 gridview의 항목입니까? GRIDVIEW 코드 :gridview에서 radiobuttonlist 찾기

<asp:TemplateField HeaderStyle-Width="20px"> 
         <ItemTemplate> 
          <asp:RadioButtonList ID="rbl_NIU" runat="server" RepeatDirection="Horizontal" BorderStyle="None" BorderWidth="0px" BorderColor="Transparent"> 
           <asp:ListItem Text="N" Value="1" ></asp:ListItem> 
           <asp:ListItem Text="I" Value="2" ></asp:ListItem> 
           <asp:ListItem Text="U" Value="3" ></asp:ListItem> 
          </asp:RadioButtonList>         
         </ItemTemplate> 
        </asp:TemplateField> 

과 된 .vb 코드 : 나는 모든하지만 "각 항목에 대해"의 "개체의 인스턴스로 설정되지 않았습니다 객체 참조"얻을 때마다 시도

Protected Sub gvImport_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvImport.RowDataBound 
     'Dim radio As RadioButtonList = DirectCast(e.Row.FindControl("rbl_NIU"), RadioButtonList) 
     'Dim radio As RadioButtonList = TryCast(sender, RadioButtonList) 
     Dim radio As RadioButtonList = CType(e.Row.FindControl("rbl_NIU"), RadioButtonList) 
     For Each par As Paraugs In list 
      For Each item As RadioButton In radio.Items 
       par.Write.ToString() 
      Next 
     Next 
    End Sub 

On breakpoint "라디오"는 "Nothing"을 반환합니다.

어디에서 문제가 발생합니까? 도와주세요! 감사합니다.

+0

'list'가 정의? – InSane

+0

e.Row.RowType 유형은 무엇입니까? (DataControlRowType.DataRow 여야 함) –

답변

0

당신은 gvImport.RowDataBound이 여전히 헤더를 계산합니다 실행, 그래서 당신은 하위의 상단에 if 문 빠른 필요할 때 :

If e.Row.RowType = DataControlRowType.DataRow Then 
'Look for radio button list in this 
End If