Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is there a way to retrieve the selected list item title/name? For example if I click an item say "Distributor" in custom list, how can I get this title in a string or variable?

enter image description here

share|improve this question
    
What are you trying to do? –  PirateEric Aug 6 '12 at 12:26

2 Answers 2

If you mean doing it through code you could use the getSelectedItems() method:

var items = SP.ListOperation.Selection.getSelectedItems(context);

You could then just iterate through the items and get the desired attribute:

for(i in items) 
{ 
 // do something
}

Here is an example of it in use

share|improve this answer
    
This is the only approach. There is no equivalent to this method on the server side as the selection is completely done client side in SharePoint. –  Vardhaman Deshpande Aug 6 '12 at 15:12

You can use CAML and SPQuery:

private SPListCollection GetDecriptionItems(SPList list)
{
  SPQuery query = new SPQuery()
  {
    Query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Distributor'></Value></Eq></Where><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy>"
  };
  return list.GetItems(query);
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.