<asp:GridView runat="server" ID="GridView1"  AutoGenerateColumns="False"  AllowPaging="True" OnPageIndexChanging="Repeater1_PageIndexChanging">
    <Columns>
    <asp:TemplateField>
   
   <ItemTemplate>
   <table style="width:250px; height:30px; border-bottom:solid 1px #888; float:right;" class="table_content">
     <tr>
     <td style="width:35%">     
     <asp:CheckBox runat="server" ID="chk_numb"/>
     <asp:HiddenField runat="server" ID="h_numb" Value='<%#Eval("numb") %>' />
     <%#Eval("cnname") %>     
     </td>
   
     <td style="width:35%"><%#Eval("curlevel") %></td>
     <td style="width:30%">
     <asp:Label runat="server" ID="Lable" Text='<%#Eval("cc") %>'/></td>
     </tr>
   </table>
   </ItemTemplate>
   </asp:TemplateField>
   </Columns>
   </asp:GridView>请问怎样用javascript判断
当checkbox选择某行时,它要判断同一行label里的值,如果它>8,Checkbox的 checked属性为false.请问怎样根据

解决方案 »

  1.   

      <asp:CheckBox runat="server" ID="chk_numb" onclick='setChecked(this)'/>
     function setChecked(chk){
    var tr= chk.parentNode.parentNode;
    if(parseInt( tr.cells[tr.cells.length-1].getElementsBytagName('span')[0].innerHTML)>8){
    chk.checked = false;
    }
    }
      

  2.   

    for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    System.Web.UI.WebControls.Label lbl= (System.Web.UI.WebControls.Label)gvHouseInfo.Rows[i].FindControl("Lable");
                    if (int.Parse(lbl.Text)>8)
                    {
                        HtmlInputCheckBox cbo= (HtmlInputCheckBox)gvHouseInfo.Rows[i].FindControl("CheckBox ");                     cbo.Checked=false;
                    }
                }
      

  3.   

    1楼的测试没有通过哦,  不知道我写错了还是问题出在哪里。if(parseInt( tr.cells[tr.cells.length-1].getElementsBytagName('span')[0].innerHTML)>8)里面的"span"是哪个控件的ID啊?