删除Gridview中的一行导致问题 [英] Delete a Row in Gridview causing a problem
问题描述
使用OnRowCommand在Gridview中删除行时,发生此错误.
错误:未处理的GridView Jobgrid触发了事件RowDeleting.
如何解决此错误.请回复
While Delete a Row in Gridview using OnRowCommand this error was occured.
Error: The GridView jobgrid fired event RowDeleting which wasnt handled.
How to resolve this error.Please reply
推荐答案
尊敬的Anuj,
在执行删除命令的代码上,尝试将所有现有数据项(要删除的行除外)添加到数据表中,而该数据表的datagrid中的列数相同.因此,此新数据表将具有除要删除的行以外的所有记录,然后再次将其绑定到网格.这肯定会解决您的问题.
如果ti帮助您,请将此标记为您的答案.
谢谢
Dear Anuj,
On the deleting command execution of the code try to add all the existing data items (other than the row which you want to delete) into a datatable with same no of columns in datagrid. So this new datatable will have all the records other than the row which you want to delete then bind the same to your grid again. This will definitely solve your probelm.
Mark this as your answer if ti helps you out.
Thanks
尊敬的Anuj,
删除行时,将触发RowDeleting事件.
如果您不希望发生此异常,请实现一个将处理RowDeleting事件的方法.
代码在这里:-
Dear Anuj,
When a row is being deleted the RowDeleting event is fired.
If you don''t want this exception to occur, implement a method that will handle the RowDeleting event.
Here the Code goes:-
if (CommandName.ToLower().Equal("delete") && gridViewDeletingEventHandler == null)
{
throw new HttpException("haha...I used hardcoded strings and it passed code review.");
}
因此,您的选择是:
处理OnRowDeleting事件(即使您不必在事件处理程序中执行任何操作……确实非常有用).或者,您可以将CommandName更改为"Delete"之外的其他名称,例如说"DoIt ... DoItNow",然后您就不必处理该事件.
如果有帮助,请标记为您的答案.
谢谢
So your options are:
Handle the OnRowDeleting event (even though you don''t have to do anything in the event handler...really really useful). Or you can change the CommandName to something other than "Delete" like say "DoIt...DoItNow" and then you don''t have to handle the event.
Please mark this as your answer if it helps you out.
Thanks
瓦伦,
当我放这段代码时,它给出了一个错误,例如gridViewDeletingEventHandler
错误:代码中不存在gridViewDeletingEventHandler的名称.
当我使用此GridViewDeletedEventHandler
错误:它是一种类型,但像变量一样使用
我必须要做的.我必须在RowCommand事件中执行该操作.
请让我知道.
Hi Varun,
when i put this piece of code its gives an error like in that gridViewDeletingEventHandler
error:The name of the gridViewDeletingEventHandler does not exist in the code .
when i used this GridViewDeletedEventHandler
error:Its a type but is used like a variable
what i have to do.I have to perform that action in RowCommand event.
Please let me know.
这篇关于删除Gridview中的一行导致问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!