This is a migrated thread and some comments may be shown as answers.

Combobox data bindng using SharePoint web service.

1 Answer 56 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kaustubh Wadi
Top achievements
Rank 1
Kaustubh Wadi asked on 16 May 2011, 02:15 PM

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

1 Answer, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 20 May 2011, 09:19 AM
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
Tags
ComboBox
Asked by
Kaustubh Wadi
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or