行删除问题 [英] Row Deleting Problem

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

问题描述

 sub GridView1_RowCommand(ByVal Sender as Object,ByVal e as GridViewCommandEventArgs)
dim index as integer=Convert.Toint32(e.CommandArgument)
dim id=GridView1.Rows(index).cells(0).Text
if e.CommandName="Delete"
Delete() ''This the function to delete rows from DB table
end if</pre>



单击带有



When the Image Button with the

commandName "Delete"

的图像按钮时,功能
"GridView1_RowCommand(ByVal发送方为对象,ByVal e为GridViewCommandEventArgs)"
被调用...
但是在删除该行之后,控件再次返回到相同的功能,并且在第一次调用自身时删除该行,它显示错误...?

is clicked the function
"GridView1_RowCommand(ByVal Sender as Object,ByVal e as GridViewCommandEventArgs)"
gets invoked...
But after deleting the row the control again comes back to the same function and as the row is deleted in the first calling itself ,it shows error...?
How to avoid calling twice the same function?

推荐答案

听起来像一个已知问题!
在这里查看:两次触发的GridView RowCommand事件 [ ^ ]

有一个简单的解决方案.将buttoncolumn 转换为templatecolumn.然后添加imagebutton:
Sounds like a known issue!
Look here: GridView RowCommand Event Firing Twice [^]

There is a simple solution to it. Convert the buttoncolumn to a templatecolumn. Then add an imagebutton:
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CommandName="Delete" CommandArgument='<%# Eval("SomeValue") %>'

ImageUrl="~/Images/extras/addtocart.gif" />
</ItemTemplate>
</asp:TemplateField>


在此行命令之后将仅触发一次.


After this Row command would fire only once.


我猜想您的delete函数中有某些原因引起了它.
第二次引发事件时CommandSource的值是什么?
I guess there is something in your delete function which is causing it.
What''s the CommandSource value when the event is raised 2nd time?


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

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