views:

26

answers:

1

Is there a way to get just the selected items of a document library from the server side? I was looking for something like this:

SPDocumentLibrary docLib = web.Lists[list.Title] as SPDocumentLibrary;
SPListItemCollection items = docLib.Items;
foreach (SPListItem item in items){
  //if (item.Selected)
}
+1  A: 

The view you see in the Document Library is rendered by XSL, so there is no direct option that will allow you get the list of selected items from server side code. But there is an alternate that I can suggest.

Article in this link suggest how to get selected items in javascript code, you can use similar code and fill in a hidden box with those values & use them at server side. You might need to add a custom ribbon command to achive this.

Kusek