how to get lookup field values in sharepoint using silverlight

how to get lookup field values in sharepoint using silverlight:

you can retrieve  the  lookup  value  in  client  object  model  as  follows

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using  System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace lookupvalue
{
public partial class MainPage : UserControl
{
ClientContext cc;

public MainPage()
{

InitializeComponent();
cc = new ClientContext(ApplicationContext.Current.Url);
cc.Load(cc.Web);
listobj = cc.Web.Lists.GetByTitle("your list name");
List s = cc.Web.SiteUserInfoList;
cc.Load(listobj);
CamlQuery cml = new  CamlQuery();
cml.ViewXml ="<view/>";
_lsititemcoll = listobj.GetItems(cml);
cc.Load(_listitemcoll);
cc.ExecuteQueryAsync(new ClientRequestSucceededEventHandler(OnRequestSucceeded), null);

}
private void OnRequestSucceeded(Object sender, ClientRequestSucceededEventArgs args)
{

// This is not called on the UI thread.
Dispatcher.BeginInvoke(datacon);

}
private void datacon()
{
foreach(ListItem li in _listitemcoll)
{

FieldLookupValue  fvalue  =   li["lookup column  name"]  as FieldLookupValue;
listBox1.Items.Add(fvalue.LookupValue);

}
}
}

Comments

Popular posts from this blog

Upload Single/Multiple file by using the REST API and jQuery SharePoint 2013

Add content type to SharePoint List/Library using REST API

A type named 'SP.Data. could not be resolved by the model error