SPGridView and SP Menufield for approving list items from SPlist
I am using spgridview for showing listdata,al开发者_运维知识库so using spmenufield.
I need to perform approve operation on any selected/clicked item from spgridview.
Can you please help,how can i achieve this?
There are no options to directly Approve the items using the SPMenuField, what you can do is to write up a JavaScript call that will get the details of the Item and redirect to the default Approval Page.
By default SharePoint approval page will be of format
_layouts/approve.aspx?List={F723A0FD-9072-46C6-A4B6-BBB21538CB68}&ID=112
Refer to this link for more details on SPGridView
It sounds like you already have the code set up so all you need to do is update the list item.
To approve the item, update the _ModerationStatus
to 0
.
Or, I believe you can use the API (simply wraps the above into the SPModerationInformation class):
SPListItem item = list.GetItemById(id);
item.ModerationInformation.Status = SPModerationStatusType.Approved;
item.Update();
精彩评论