如何从asp.net中的数据表和数据行生成gridview时删除gridview行 [英] how to delete a gridview row when gridview is generated from datatable and datarows in asp.net
问题描述
您好,我正在制作一个asp.net webform页面....到目前为止,我已经从datatable和datarow生成了我的gridview! ,我还放了一个删除btn,它实际上是一个asp:commandfield ...在gridview设置中可用....现在我想要的是当用户点击DELETE BUTTON时,当前行被删除!!到目前为止,我还没有实现SQL数据库或SQL数据表....请帮助我.....更多详细信息请打开此链接我已附加该图像.....
链接:
https:/ /drive.google.com/file/d/0B8NFUJX6CxVzeVR0SnFkcG9TNDg/edit?usp=sharing [ ^ ]
Hello, I am making an asp.net webform page .... so far i have generated my gridview from datatable and datarow ! , i have also put a delete btn which is actually a asp:commandfield ... available in gridview settings .... now that i want is that when a user clicks that DELETE BUTTON, that current row gets deleted !! so far i have not implemented SQL Database or SQL DATA TABLES .... please help me out ..... for more detailed info please open this link i have attached that image .....
Link :
https://drive.google.com/file/d/0B8NFUJX6CxVzeVR0SnFkcG9TNDg/edit?usp=sharing[^]
推荐答案
关于删除事件
GridView1.DeleteRow( GridView1.SelectedIndex);
On Delete Event
GridView1.DeleteRow(GridView1.SelectedIndex);
首先获取某些集合中的所有数据,比如说,在列表中< t>< / t>
。
将此列表作为数据源分配给Gridview。
并执行类似 INSERT-UPDATE-DELETE此列表< t> 的操作,然后再将其绑定到Gridview。
我没有任何实际的例子,所以我无法通过它来解释。但是,我刚刚做了这个,并且工作得很好。
请记住,你所要做的就是在List< t>周围玩游戏。而不是数据库:)
-KR
First get all the data in some collection, let's say, in aList<t></t>
.
Assign this List as a DataSource to the Gridview.
And perform the operations like, INSERT-UPDATE-DELETE on this List<t> and then again bind it to the Gridview.
I don't have any working example, so I can't explain it through it. But yeah, I have done this a while ago, and worked properly.
Remember, all you have to do is, play around the List<t> rather than Database :)
-KR
这篇关于如何从asp.net中的数据表和数据行生成gridview时删除gridview行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!