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"];
}
精彩评论