gridview中的多个删除 [英] multiple delete in gridview

查看:62
本文介绍了gridview中的多个删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

指数超出范围。必须是非负数且小于集合的大小。

参数名称:index



Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

protected void btnDelete_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in gv_1.Rows)
{

CheckBox cb = (CheckBox)row.FindControl("checkBoxD");

if (cb.Checked)
{

BBLL delBLL = new BBLL();

string message = "";

int foodID = Convert.ToInt32(gv_1.DataKeys[row.RowIndex].Value);
message = evtBLL.Delete(foodtID);


gv_1.DataBind();


}

}

推荐答案

我认为问题在这里



i think the problem is here

if(gv_1.RowIndex > 0)
            {
int foodID = Convert.ToInt32(gv_1.DataKeys[row.RowIndex].Value);
message = evtBLL.Delete(foodtID);
}


这篇关于gridview中的多个删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆