ListView的edit delete
今天在ListView中添加了两个按钮:
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="Style/IMG/edit.gif" CommandName="Edit" CommandArgument='<%# Eval("QuestionId") %>' />
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="Style/IMG/delete.gif" CommandName="Delete" CommandArgument='<%# Eval("QuestionId") %>' />
并在ItemCommand事件中分别进行处理,结果一直报错:没有处理ItemDeleting事件,我就纳闷,我没有ItemDeleting这个事件啊。
结果发现ListView会自动将CommandName="Delete"的按钮关联ItemDeleting事件。
解决办法:CommandName="Delete"改为CommandName="DeleteQuestion"
搞定!