我们如何在不使用数据源的情况下从数据绑定的gridview中删除行 [英] how can we delete row from data bounded gridview without using datasource

查看:62
本文介绍了我们如何在不使用数据源的情况下从数据绑定的gridview中删除行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何从数据绑定的gridview中删除行

how can we delete row from data bounded gridview

gridview1.datasource=List<Object>
gridview1.databind();


我正在使用


I am using

List<Object>

来绑定girview.我想删除行而不从列表中删除相应的对象
PLZ 请帮忙.

for binding girview .I want to delete row without deleting corresponding object from list
PLZ Please help.

推荐答案

在这种情况下,我认为从gridview中隐藏行是更好的选择. 您可以按照以下 http://stackoverflow.com/questions/114521/hide-asp-net- gridview-row [ ^ ]

仍然我没有使用过,但我认为这可能对您有帮助
In that case I think hiding the row from gridview is better option.
You can follow this http://stackoverflow.com/questions/114521/hide-asp-net-gridview-row[^]

Still I have not used but I think it may helpful to you


您好,

要从列表中删除值,可以使用linq查询.

单击删除按钮后,将命令参数作为该行的唯一标识值传递.在网格视图的行命令事件中检查命令名称,并编写以下内容:

Hi,

To delete the values from list you can use linq queries.

On click of delete button pass the command argument as unique identity value of the row. Check your command name in row command event of grid view and write the following:

protected void gvSumAssured_ItemCommand(object source, GridViewCommandEventArgs e)
{
  if (e.CommandName == "DeleteValue")
   {
       int id=Convert.toInt32(e.CommandArgument);
       List<string[]> list = new List<string[]>;
       var a = from arrStr in list
                        where arrStr[0].Equals(id)
                        select arrStr;
       list.Remove (a.Single());
   }
}



祝一切顺利.
--AK



All the best.
--AK


这篇关于我们如何在不使用数据源的情况下从数据绑定的gridview中删除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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