如何从网格视图中删除记录,并在按钮单击时更新数据库中的相关某些列数据 [英] How can we delete a record from a grid view and update related some columns data in database on button click

查看:91
本文介绍了如何从网格视图中删除记录,并在按钮单击时更新数据库中的相关某些列数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好..



我的问题是我在网格视图中有一个删除按钮。如果我点击删除按钮,需要删除特定行,并且需要更新该行的某些列,只需点击相同的按钮即可。





示例如果我单击删除该行需要删除的行...该行具有在删除前处于活动状态的状态列,在单击删除后该列状态应更改为删除,并且应删除行并再删除一列id应该更改为null。



我尝试过:



很困惑如何在单击上做两个操作



帮助??

建议??

Hello everyone..

My problem is I have a delete button in grid view. if i click on delete button that particular row need to be deleted and some columns of that row need to be updated which on same button click.


example if i click delete that row that row needs to be deleted..that row has Status column which is active before deleting, after clicking delete that column status should change to delete, and row should be deleted and one more column that id should change to null.

What I have tried:

very confused how to do both operations on single click

help??
suggestions??

推荐答案

<asp:BoundField HeaderText="ID" DataField="Id" ItemStyle-CssClass="hidecol" HeaderStyle-CssClass="hidecol" >
</asp:BoundField>



CSS


CSS

<style type="text/css">
  .hidecol
  {
    display: none;
  }
</style>







protected void btnDelete_Click(object sender, EventArgs e)
       {
           Button btn = (Button)sender;
           GridViewRow gvr = (GridViewRow)btn.NamingContainer;
           int idcolumnIndex = 5; // check this index
           string id = gvr.Cells[idcolumnIndex].Text;
       }


这篇关于如何从网格视图中删除记录,并在按钮单击时更新数据库中的相关某些列数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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