无法从gridview中删除特定行 [英] Unable to delete specific row from gridview

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

问题描述

我在删除gridview中的特定行时遇到问题。



这是错误消息:



输入字符串的格式不正确


此特定行的




int shoppingCartID = Convert.ToInt32(delCart.CommandArgument);



任何想法为什么?



除此之外, delCart.CommandArgument的值是userID和shoppingCartID:



int userID = Convert.ToInt32(Session [userID] =3);

int shoppingCartID = Convert.ToInt32(delCart.CommandArgument);

del.DeleteSCitems(userID,shoppingCartID);

hi i have issues deleting a specific row in the gridview.

this is the error message:

Input string is not in a correct format

for this particular line

int shoppingCartID = Convert.ToInt32(delCart.CommandArgument);

any idea why?

in addition to this, the value for delCart.CommandArgument is userID and shoppingCartID :

int userID = Convert.ToInt32(Session["userID"] = "3");
int shoppingCartID = Convert.ToInt32(delCart.CommandArgument);
del.DeleteSCitems(userID, shoppingCartID);

推荐答案




如果您使用的是GridView_RowCommand:



Hi
Follow the below one, If you are using GridView_RowCommand:

GridViewRow gRow = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer);
int RowIndex = gRow .RowIndex; 





使用行索引获取所选行ID并删除记录。



点击Delete boutton,它在项目模板内:



Use the row index and get the selected row id and delete the record.

Click on Delete boutton and it is inside item template:

GridViewRow gRow = (GridViewRow)((ImageButton)(sender)).NamingContainer;
string strId = ((HiddenField)gRow.FindControl("hdnId")).Value;





使用strId并删除。



问候

遗嘱



use the strId and delete.

Regards
Wills


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

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