开发者

How to delete specific row in the gridview when item is binded from session

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?


As you said you want to delete the selected row, for this you can use RowIndex to delete the selected row, GridView has a method DeleteRow which takes an index of row as a parameter.


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

DatKeyNames="UniqueId"

Then when you want to delete a row just get the UniqueId value from DataKeys

GridView1.DataKeys[DeleteRowIndex].Value

Where DeleteRowIndex is the index of the row being deleted from the grid view

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜