Gridview行删除错误? [英] Gridview row deleting Error?

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

问题描述

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
  {

int ipimg = (int)GridView1.DataKeys[e.RowIndex].Value;
 objcmd = new SqlCommand("DELETE FROM TBL_PDT_IMG WHERE IMG_ID='" + ipimg + "'", con);
objcmd.ExecuteNonQuery();
  bind();
}










i have error on delete Rows.

that Error is <pre lang="sql">Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index





我在说什么?请帮帮我



what i am say? please help me

推荐答案

尝试类似的事情,

int userid = Convert.ToInt32(gvDetails.DataKeys [e.RowIndex] .Values [ UserId]。ToString());



-KR
Try something like,
int userid = Convert.ToInt32(gvDetails.DataKeys[e.RowIndex].Values["UserId"].ToString());

-KR


当我们的索引不正确时,我们恢复了这个错误所以请检查你索引那些正在删除的时间。
we r revived this error when our indexing is not correct so pls check you indexing those are passing time of delete .


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

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