如何从GridView中删除行? [英] How to delete row from gridview?

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

问题描述

我使用asp.net 2005年C#中使用GridView控件。

如何从GridView中删除特定行。

我写以下code,但它不工作...

 的DataRow博士= dtPrf_Mstr.NewRow();
dtPrf_Mstr.Rows.Add(DR);
GVGL code.DataSource = dtPrf_Mstr;
GVGL code.DataBind();INT ICOUNT = GVGL code.Rows.Count;
的for(int i = 0; I< = ICOUNT;我++)
{
    GVGL code.DeleteRow(I)
}
GVGL code.DataBind();


解决方案

您要删除在GridView的行但后来你会和调用数据绑定再次这是刚刚刷新GridView控件到相同的状态,原来的数据源是在

无论是从数据源中删除它​​,然后数据绑定,或和数据绑定在GridView不redatabinding删除它。

I am using asp.net 2005 c# using gridview control.

How can i delete particular row from gridview.

I wrote following code but it's not working...

DataRow dr = dtPrf_Mstr.NewRow();
dtPrf_Mstr.Rows.Add(dr);
GVGLCode.DataSource = dtPrf_Mstr;
GVGLCode.DataBind();

int iCount = GVGLCode.Rows.Count;
for (int i = 0; i <= iCount; i++)
{
    GVGLCode.DeleteRow(i);
}
GVGLCode.DataBind();

解决方案

You are deleting the row from the gridview but you are then going and calling databind again which is just refreshing the gridview to the same state that the original datasource is in.

Either remove it from the datasource and then databind, or databind and remove it from the gridview without redatabinding.

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

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