从网格视图中删除选定的行 [英] Remove a selected row from grid view

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

问题描述

大家好,
我的问题是我有一个绑定到表的网格视图.当我借助复选框检查特定的行时,应从网格视图中删除该行,而不是从数据库中删除该行.如何从网格中删除特定的行视图.
感谢您的问候,
Amit

Hello All,
My problem is that I have a grid view which is binded to a Table.When I check a particular row with the help of check box ,that row should removed from grid view but not from the database.How to remove the particular row from grid view.
Thanks with Regards,
Amit

推荐答案

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
   {
       GridView1.SelectedRow.Visible = false;
   }


或者您可以使用JavaScript隐藏行-
Or you can hide the row using JavaScript -
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        LinkButton lnk = e.Row.Cells[0].Controls[0] as LinkButton;
        if (lnk != null)
        {
            lnk.OnClientClick = string.Format("document.getElementById('{0}').style.display = 'none'; return false;", e.Row.ClientID);
        }
    }
}



此代码假定选择"链接在第一列中.



This code assumes that the "Select" link is in the first column.


这篇关于从网格视图中删除选定的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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