如何从Gridview删除不限于数据源的行 [英] how to Delete a Row from Gridview which is not bounded to datasource

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

问题描述

亲爱的

请任何人可以告诉我
如何从gridview删除未绑定的行
数据源.

我没有使用任何数据源在gridview中显示数据
我正在使用存储过程,并且在从表中获取行之后
我正在填充gridviewdatasource.

现在在gridview的中间有一行
我要删除的内容.
我该怎么做.

Deletecommand在这里不起作用.

Dear

Please any one can tell me
How to Delete a row from gridview which is not bounded to
datasource.

I am not used any datasource to show data in gridview
I am using a stored procedure and after i getting rows from table
i am filling to gridviewdatasource.

Now there is row in the middle of the gridview
that i want to delete.
How can i do that.

Deletecommand is not working here.

推荐答案

u可以使用项目模板并将按钮放置在网格视图中.将表的主键存储在按钮的命令名属性中.

< asp:GridView .....>
<专栏>
....
.....
< asp:TemplateField>
< ItemTemplate>
< asp:按钮ID ="BTdelete" runat ="server" Text ="Edit" CommandName =''<%#Bind("EID")%>''OnCommand ="BTEdit_Command"></asp :按钮>
</ItemTemplate>
</asp:TemplateField>
</列>
</asp:GridView>
在cs文件中,使用事件获取命令名称,然后从表中查找数据并将其删除.
u can use item template and place a button inside gird view. store your table''s primary key in button''s command name property.
Ex
<asp:GridView .....>
<Columns>
....
.....
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="BTdelete" runat="server" Text="Edit" CommandName=''<%# Bind("EID") %>'' OnCommand="BTEdit_Command"></asp:Button>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
in cs file get command name using event and find data from table and delete it.


嗨Jagadeesh Bollabathini,
我认为您必须为新添加的行设置脏标志,然后使用循环从网格视图中删除这些行.
Hi Jagadeesh Bollabathini,
I think you have to set dirty flag for newly added row and then remove those row from grid view using loop.


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

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