当项目从会话绑定时如何删除网格视图中的特定行
我有一个网格,我在其中绑定会话变量中的项目,其中网格中大约有 5 个相似的项目,我必须删除特定的选定行,当所有列都有相似的项目和字段时,我可以根据什么删除选定的项目?
I have grid where i am binding items from session variable , where their around 5 similar items in the grid, i have to delete a specific selected row , on what basis i can delete the selected item, when all the columns have similar items and feilds?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如您所说,您要删除选定的行,为此您可以使用
RowIndex
删除选定的行,GridView
有一个方法DeleteRow
,它将行索引作为参数。As you said you want to delete the selected row, for this you can use
RowIndex
to delete the selected row,GridView
has a methodDeleteRow
which takes an index of row as a parameter.如果会话变量中的项目有一个用于标识的属性,那就很容易了。
假设属性名称为 UniqueId
当将数据源绑定到绑定之前设置的 gridview 时
然后当您想要删除一行时只需从 DataKeys 中获取 UniqueId 值
其中 DeleteRowIndex 是从网格视图中删除的行的索引
If the items in the session variable have a Property used for identification that it is very easy.
Let's say that property name is UniqueId
When Binding the datasource to the gridview set before binding
Then when you want to delete a row just get the UniqueId value from DataKeys
Where DeleteRowIndex is the index of the row being deleted from the grid view