从数据集中完全删除一行 [英] Deleting a row completely from a dataset

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

问题描述

我的网格视图上有一个删除按钮。在点击删除按钮后,该行应从会话中完全删除
。我目前正在执行以下操作:

I have a remove button on my gridview. On Clicking the remove button , the row should be completely removed from the session. I am currently doing the following :

protected void gvMainLog_RowCommand(Object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Remove")
        {

            GridViewRow rowSelect = (GridViewRow)(((Button)e.CommandSource).NamingContainer);
            int rowindex = rowSelect.RowIndex;

            DataSet ds =  ((DataSet)Session["old"]);

            ds.Tables[0].Rows[rowindex].Delete();

            Session["old"] = ds;

            gvMainLog.DataSource = Session["old"];
            gvMainLog.DataBind();

        }

问题是:

ds.Tables[0].Rows[rowindex].Delete();

仅删除该行中的内容。当我查看数据集时,它显示了一个空行。

removes only the content in that row. When I look at the dataset , it shows an empty row.

有没有办法删除整行,而不显示空行?

Is there a way I can remove the entire row, without it showing an empty row ?

推荐答案

尝试调用

ds.AcceptChanges() 

row.Delete()。

after row.Delete().

这篇关于从数据集中完全删除一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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