Brzo i jednostavno: Nabavite SPFolder jednog SPListItem u Event prijemnik

Mrzim to priznati, but I struggled with this one all day. My event receiver needs to update a field of its parent folder. This little bit shows how to do it:

privatni poništiti UpdateParentFolder(SPItemEventProperties Svojstva)
{

SPFolder thisItemFolder = properties.ListItem.File.ParentFolder;
thisItemFolder.Item["ZZ Approval Status"] = "Good news, svako!";
thisItemFolder.Item.Update();


} // UpdateParentFolder

U tom slučaju, I’m working with a document library and the properties are coming from an ItemAdded event.

The trick is that you can’t get the SPFolder of the item directly from the item itself (i.e. properties.ListItem.Folder is null). Umjesto toga, go to the list item’s associated File and get the File’s folder.

</kraj>

Pretplatite se na moj blog!

Technorati Tags:

Jedna misao o „Brzo i jednostavno: Nabavite SPFolder jednog SPListItem u Event prijemnik

Dopust jedan Odgovor

Vaša email adresa neće biti objavljena. obavezna polja su označena *