复制代码 代码如下:
<asp:Button Text="Delete" runat="Server"
CausesValidation="false" />
<asp:GridView runat="server" DataKeyNames="CutterTypeId" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<ItemStyle BorderWidth="1" BorderColor="#c0c0c0" />
<ItemTemplate>
<asp:CheckBox runat="server" />
</ItemTemplate>
</asp:TemplateField>
<!--
other column templateField
-->
</Columns>
</asp:GridView>
复制代码 代码如下:
protected void Page_Load(object sender, EventArgs e)
{
this.ButtonDelete.Attributes.Add("onclick", "return ConfirmOnDelete();");
}
protected void ButtonDelete_Click(object sender, EventArgs e)
{
//do delete something
}
复制代码 代码如下:
function ConfirmOnDelete() {
if (document.getElementById("<%= GvCutterType.ClientID %>") == null) {
return false;
}
var objgv = document.getElementById("<%= GvCutterType.ClientID %>");
var rc = objgv.rows.length;
var y = 0;
for (var i = 0; i < rc; i++) {
var getInput = objgv.rows[i].cells[0].getElementsByTagName("input");
if (getInput[0].type == "checkbox") {
if (getInput[0].checked) {
y = y + 1;
}
}
}
if (y <= 0) {
alert("首先选择想要删除的记录。");
return false;
}
if (confirm("以下选择的记录将被删除。") == true)
return true;
else
return false;
}
新闻热点
疑难解答
图片精选