用asp.net里的GridView实现编辑删除时, SelectedIndexChanged 事件中如何区分按钮?
问题描述:
添加了编辑和删除,但是双击后都触发的是SelectedIndexChanged事件,在事件里应该怎么区分编辑还是删除呢?
<asp:CommandField ButtonType="Button" ShowEditButton="True" >
</asp:CommandField>
<asp:CommandField ButtonType="Button" ShowDeleteButton="True" >
</asp:CommandField>
答
Gridview 自带的功能 OnRowUpdating OnRowDeleting OnRowCancelingEdit
CommandName="Update" Text="Update">/asp:LinkButton
CommandName="Cancel" Text="Cancel" >/asp:LinkButton
答
sender这个参数等于哪个按钮,就是谁触发的