Combobox data bindng using SharePoint web service.

2 posts, 0 answers
  1. Kaustubh Wadi
    Kaustubh Wadi avatar
    26 posts
    Member since:
    Apr 2010

    Posted 16 May 2011 Link to this post

    Hello Telerik Team,

    I am using Silverlight Radcombobox in one of my SharePoint application. I am able to bind sharepoiint list items to combo box using following approach.

    XNamespace ns = "#RowsetSchema"
                var query = from x in e.Result.Descendants() 
                            where x.Name == ns + "row"
                            select x.Attribute("ows_Title").Value.Split(',')[0]; 
                combobox.ItemsSource = query;

    Now what i want is, the display text for combo box should be from Title column of sharePoint list,
    But i want the ID of selected Title in code behind file.
    I am getting 'title' from combobox.selectedvalue statement. How can i get ID using combobox.selectedvalue statement?
    Can I set selectedvaluePath property to sharepoint list's ID column in code behind file.?

    Please guide me.

    Many Thanks,
    Kaustubh Wadi

  2. Valeri Hristov
    Valeri Hristov avatar
    2252 posts

    Posted 20 May 2011 Link to this post

    Hello Kaustubh,

    As far as I understand, you want to display the Title property in RadComboBox, but use the ID property. For this to happen you need to bind the control to a collection of objects that have Title and ID properties, something like this:
    public class DataItem
        public int ID { get; set; }
        public string Title { get; set; }

    // You should modify your Linq query and use it here instead of the new list
    combobox.ItemsSource = new List<DataItem>();
    combobox.DisplayMemberPath = "Title";
    combobox.SelectedValuePath = "ID";


    var id = combobox.SelectedValue; // The ID of the selected DataItem

    I hope this helps.

    All the best,
    Valeri Hristov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top