日期:2014-05-18  浏览次数:20845 次

模板页中用JS增加删除CheckBoxList。版主周末在线不?
<asp:CheckBoxList ID="CheckBoxListGroup" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
  </asp:CheckBoxList>
我做了一个最基本的测试:
  var check = document.createElement( "input "); 
  check.type= "checkbox "; 
  check.value= "1 "; 
  var list = document.getElementById("<%=CheckBoxListGroup.ClientID %>");
  var row = list.insertRow(); 
  var cell=row.insertCell(); 
  cell.appendChild(check); 
  check.checked=true; 

但是list.insertRow(); 就报错了,我的页面是个模板页,不知道是不是有影响。
list.rows[i].removeNode(true);也是不行的,请高手指教。


------解决方案--------------------
CheckBoxList里没有任何项的话,是不会Render到前台的,所以你的前台根本就没有id为CheckBoxListGroup.ClientID的table,所以会报错