简体   繁体   English

ASP.Net列表视图

[英]ASP.Net Listview

I would like to fire the ListView1_ItemUpdating event on ListView1_ItemDeleting. 我想在ListView1_ItemDeleting上触发ListView1_ItemUpdating事件。

Reason is whenever user press delete in listview, the record should not be physically delete from the database. 原因是每当用户在列表视图中按Delete键时,都不应从数据库中物理删除该记录。 There is a bit in table I need to just make it true so need to update that record. 表中有一点我需要使其正确,因此需要更新该记录。

So How could I do this? 那么我该怎么做呢?

Thanks. 谢谢。

Write a common function to Update database and call it in both ListView1_ItemUpdating and ListView1_ItemDeleting events . 编写一个公共函数来更新数据库 ,并在ListView1_ItemUpdatingListView1_ItemDeleting事件中调用它。

Pass entity to be updated to that function , when it is called from ListView1_ItemDeleting the bit should set true. ListView1_ItemDeleting调用实体时,将要更新的实体传递给该函数,将位设置为true。

Use this approach maybe useful. 使用此方法可能有用。

void ContactsListView_ItemUpdating(Object sender, ListViewUpdateEventArgs e)
{
  Update();      
}  
protected void CategoriesListView_OnItemDeleting(object sender, ListViewDeleteEventArgs e)
{
  Update();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM