<asp:Repeater ID="rptLemmaList" runat="server">
              <ItemTemplate>
              <tr >
                <td align="center" >
                    <input id="lemmaId" type="hidden" value="<%#Eval("LemmaId") %>" /><input type="checkbox" id="cbLemmaId" runat="server" /> </td>
                <td align="center" ><%#Eval("Title")as string %></td>
                <td align="center" ><%#getDesc(Eval("Description")as string) %></td>
                <td align="center" ><%#Eval("CreateName")as string %></td>
                <td align="center" ><%#Eval("CreateTime","{0:yyyy-MM-dd}")as string %></td>
                
                <td align="center">
                <a href="LemmaShow.aspx?LemmaId=<%#Eval("LemmaId") %>">查看</a>
               
                </td>
              </tr>
            </ItemTemplate>
            </asp:Repeater>
string postValue = null;
            HtmlInputCheckBox cb1 = new HtmlInputCheckBox();
            HtmlInputHidden hd=new HtmlInputHidden();            for (int i = 0; i < rptLemmaList.Items.Count; i++)   
            {
                hd = (HtmlInputHidden)rptLemmaList.Items[i].FindControl("lemmaId");
                cb1 = (HtmlInputCheckBox)rptLemmaList.Items[i].FindControl("cbLemmaId");
                if (cb1.Checked)
                {
                    
                    postValue += "," + hd.Value.ToString();
                }
            }找得到cb1,但是找不到htmlinputHidden,每次执行到postValue += "," + hd.Value.ToString();时就提示hd没有设置到对象,hd是null

解决方案 »

  1.   

      
    少了runat="server"
    <input id="lemmaId" type="hidden" value="<%#Eval("LemmaId") %>" runat="server"/>
      

  2.   

    红色的地方:双引号改单引号:
    <input id="lemmaId" type="hidden" value='<%#Eval("LemmaId") %>runat="server"/>
      

  3.   

    哦.你的代码有问题,应该是:<input id="lemmaId" type="hidden" value='<%#Eval("LemmaId") %>' runat="server"/>注意:加runat="server",
         还有value用单引号括起来(因为里面有双引号)
      

  4.   

    <input id="lemmaId" type="hidden" value=' <%#Eval("LemmaId") %>' runat="server"/>先单引号再双引号
      

  5.   

    我ca,我回的不对么? 一分没给!CA!