function TotalChecked()
{
var count=0;
var GridView2 = document.getElementById("<%=gviewNotPublishTrade.ClientID %>");
for(i = 1;i < GridView2.rows.length; i++)
{
if( GridView2.rows[i].cells[0].getElementsByTagName("INPUT")[0].checked)
{
count++;
}
}
if(count>=1)
{
return confirm("你确定要发布吗?");
}
else
{
alert("请至少选中一条记录!");
return false;
}
}
2.CheckBox全选
function CheckAll(checkbox)
{
var elements = checkbox.form.elements;
for(var i = 0;i < elements.length;i++)
{
if(elements[i].type == "checkbox" && elements[i].id != checkbox.id)
{
elements[i].checked = checkbox.checked;
}
}
}
引用:
<asp:TemplateField>
<HeaderTemplate>
<input type="checkbox" id="Check" οnclick="CheckAll(this)" title="全选" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="checkSingle" runat="server" />
</ItemTemplate>
<ItemStyle Width="48px" HorizontalAlign="Center" />
</asp:TemplateField>
转载于:https://www.cnblogs.com/lt2699/archive/2008/06/20/1226978.html