ASP.NET Datagrid checkbox 批量下载
有没有可能用JS实现Datagrid 勾选checkbox 批量下载?
------解决方案-------------------- <asp:TemplateColumn>
<HeaderStyle Wrap="False"></HeaderStyle>
<ItemStyle Wrap="False"></ItemStyle>
<HeaderTemplate>
<input id="Checkbox1" type="checkbox" onclick='selectAll()' />
</HeaderTemplate>
<ItemTemplate>
<input type='checkbox' id='ChkSelect' runat="server" value='<%#Eval("ID")%>' />
</ItemTemplate>
</asp:TemplateColumn>
JS
<script type="text/javascript">
function selectAll() {
// 获得用户页面中的所有的 输入功能的控件getElementById("ChkSelect").
var checkbox = document.getElementsByTagName("input");
if (checkbox[0].checked == true) {
for (var i = 0; i < checkbox.length; i++)
checkbox[i].checked = false;
}
else {
for (var i = 0; i < checkbox.length; i++)
checkbox[i].checked = true;
}
}
</script>
CS
下载按钮里面 DEMO
string s = "";
int num = 0;
for (int i = 0; i < this.AnonalousGrid.Items.Count; i++)
{
//客户端
HtmlInputCheckBox chb = (HtmlInputCheckBox)this.AnonalousGrid.Items[i].FindControl("ChkSelect");
//CheckBox chb = (CheckBox)this.Repeater1.Items[i].FindControl("CheckBox2"); //服务器端 &nb