开发者

how to edit own item in listview asp.net

开发者 https://www.devze.com 2023-03-28 00:22 出处:网络
I want to implement a comment list and use list 开发者_开发问答view to binding data. But now I have a problem that, only specific item can be deleted or edited by owner. how to config list view to do

I want to implement a comment list and use list 开发者_开发问答view to binding data. But now I have a problem that, only specific item can be deleted or edited by owner. how to config list view to do this function, thanks!


Once the list is bound (like in OnDataBound event), iterate through the items, and use logic similar to this:

foreach (ListViewDataItem item in ListView1.Items)
{
    btnDelete.Enabled = User.UserID == ListView1.DataKeys[item.DataItemIndex]["UserID"];
}
0

精彩评论

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

关注公众号