62,041
社区成员
发帖
与我相关
我的任务
分享
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
//你初始时绑定的数据代码
}
}
//下面是我自己程序里面一个按钮事件
protected void btnDelete_Click(object sender, EventArgs e)
{
String sql;
for (int i = 0; i < this.GridView1.Rows.Count; i++)//遍历控件每行
{
string Label;
bool isChecked = ((CheckBox)GridView1.Rows[i].FindControl("CheckBox1")).Checked;//获取选择框的状态
if (isChecked)//判断是否选中
{//如果选中则进行数据库操作
string id = GridView1.DataKeys[i].Value.ToString();//获取行的关键字的值,我这是绑定的关键字是id 以便删除呵呵
sql = "delete from kanwuA where articleid=" + id + "";
Conn.ExecuteSQL(sql);//对数据库进行操作
}
}
Response.Write(" <script language=javascript> alert( '删除成功'); location.href='ArticleManage.aspx';</script> ");//操作提示
Response.End();
}