2010-01-09 146 views
0

您好,我无法预先显示屏幕上复选框的所有值。 让我解释一下,我有5个复选框,例如2增强不是我想要的其他数组,其中包括2个true和其他所有5个复选框false 有人可以帮助我。从复选框中获取价值

与此同时

我试图做我创建了一个类

public class PresenzaAO  
     ( 
      public List <Presenti> listapresenti = new List <Presenti>();  
      public string conteggiototale (get;)  
      public long idalunno (get;)  
      public string radio (get;)  
     )  

     public class Present  
     ( 
      public string presents{get;set;}  
     ) 
and then in the view I created this: 



<% Using (Html.BeginForm (ModificaPresenzaAlunno "," Presence ", FormMethod.Post))  
     (%>  
    <% = Html.Hidden ("conteggiototale" Viewdata [ "conteggiototale"])%>  
    <% = Html.Hidden (idalunno "Viewdata [" student "])%>  
    <table>  
     <tr>  
      <td>  
       <% = Html.Encode (nomealunno)%>  
      </ td>  
      <td>  
       <% = Html.Encode (cognomealunno)%>  
      </ td>  
      <%  
       if (Viewdata [ "conteggio_presenze"]. ToString() == Viewdata ["conteggiototale"]. ToString())  
       (%>  
      <td>  
       Absent  
       <input type = "radio" name = "radio" checked = "checked" id = "assente_"  
        onclick = "getassentemod (<% = Viewdata [" student "]%>, 0);" value = "true_assente" />  
        This  
       <input type = "radio" name = "radio" id = "presente_" value = "false_presente"  
        onclick = "getassentemod (<% = Viewdata [" student "]%>, 0);" />  
      </ td>  
      <% Int i = 0;%>  
      <% Foreach (var p in (List <PresenzaAlunnoOra>) Viewdata [ "presenze_alunno"])  
       ( 

        i + = 1;  

      %>  
      <td>  
       <input type = "checkbox" id = "check_ <% = Viewdata [" student "] %><%= i%>" value ="<%= i%> "name =" Present "  
        onclick = "modificapresenzaalunno (this);" />  
      </ td>  
      <%)%>  
      <%)  
       else  
       (%>  
      <td>  
       Absent  
       <input type = "radio" value = "false_assente" name = "radio" id = "assente_ <% = Viewdata [" student "]%>"  
        onclick = "getassentemod (<% = Viewdata [" student "]%>, 0);" />  
        This  
       <input type = "radio" value = "true_presente" name = "radio" checked = "checked" id = "presente_ <% = Viewdata [" student "]%>"  
        onclick = "getpresentemod (<% = Viewdata [" student "]%>, 0);" />  
      </ td>  
      <% Int i = 0;%>  
      <%  
       foreach (var p in (List <PresenzaAlunnoOra>) Viewdata [ "presenze_alunno"])  
       ( 
        i + = 1;  
        if (p.presente == true)  
        ( 
      %>  
      <td>  
       <input type = "checkbox" id = "check_ <% = Viewdata [" student "] %>,<%= i%>" name = "Present"  
        checked = "checked" value ="<%= i%> "onclick =" modificapresenzaalunno (this); "/>  
      </ td>  
      <%)  

        else  
        (%>  
      <td>  
       <input type = "checkbox" id = "check_ <% = Viewdata [" pupil "]%>,<%= i%> "value ="<%= i%>" name = "Present"  
        onclick = "modificapresenzaalunno (this);" />  
      </ td>  
      <%)%>  
      <%)%>  
      <%)%>  
     </ tr>  
    </ table>  
    <input type="submit" id="btnupdatealunni" value="modifica presenze" />  
    <%)%>  
</ asp: Content> 

地方控制器参数PresenzaAO存在

我读了所有的参数,除了复选框

+0

名称attribue包含目的的空间? – 2010-01-09 21:57:51

回答

0

没有其他系统,它不包含空格,但我注意到,在复选框的名称中显示的示例缺少 说复选框的名称应该如下所示:

<input type = "checkbox" id = "check_ <% = Viewdata [" pupil "]%>,<%= i%> "value ="<%= i%>" name = "Present [<% = i% >].presents" 
        onclick = "modificapresenzaalunno (this);" /> 

但我不工作,你的复选框甚至