110,532
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Button1.Attributes.Add("onclick", "javascript:Confirm();");
}
}
protected void btDelete_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(HiddenField1.Value) && int.Parse(HiddenField1.Value) > 0)
{
for (int j = 0; j < GridView1.Rows.Count; j++)
{
CheckBox Cb = (CheckBox)GridView1.Rows[j].FindControl("Checkbox");
if (Cb.Checked)
{
int id = Convert.ToInt32(GridView1.DataKeys[j]["id"].ToString());
int flag = Productbll.proDel(id);
}
}
if (this.ddlProductLine.SelectedValue == "please choose")
{
MorenBind();
}
else
{
Bind();
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script language="javascript" type="text/javascript">
function Confirm()
{
var count=0;
var GridView = document.getElementById("<%=GridView1.ClientID %>");
for( i=1; i<GridView.rows.length; i++)
{
if(GridView.rows(i).cells(0).children(0).checked)
{
count++;
}
}
document.getElementById("<%=HiddenField1.ClientID %>").value = 0;
if(count > 0)
{
if(confirm("确定删除这" + count + "项么?"))
{
document.getElementById("<%=HiddenField1.ClientID %>").value = count;
}
}
else
{
alert("请选择删除项");
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:HiddenField ID="HiddenField1" runat="server" />
</div>
</form>
</body>
</html>