userControl/productInfor.ascx.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
namespace MyPetShop.Admin.usercontrol
{
public partial class product : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void chkAll_checkedChanged(object sender, EventArgs e)
{
//获取gridview标题行中的chkAll对象
CheckBox chkAll = (CheckBox)sender;
chkAll.Checked=true;
foreach (GridViewRow gvRow in GridView2.Rows)
{
//获取gridview数据行中chkItem对象
CheckBox chkItem = (CheckBox)gvRow.FindControl("chkItem");
chkItem.Checked =true;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow gvRow in GridView2.Rows)
{
CheckBox chkItem = (CheckBox)gvRow.FindControl("chkItem");
if (chkItem.Checked)
{
DB db = new DB();
SqlConnection con = db.GetCon();//连接数据库
con.Open();//打开连接
SqlCommand cmd = new SqlCommand("delete from Product where ProductId="+ int.Parse(gvRow.Cells[1].Text),con);
cmd.ExecuteNonQuery();
GridView2.DataBind();
}
}
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
