6 Answers, 1 is accepted
it is better if you show your xaml code .
assignUserCol.DataMemberBinding = new System.Windows.Data.Binding("UserId"); TextBlock header = new TextBlock(); header.Text = "Assign User"; ToolTipService.SetToolTip(header, "Assign a customer to a particular user"); assignUserCol.Header = header; assignUserCol.UniqueName = "Assign User"; more... Method that returns an 2 property collection via an async call to a webservice: assignUserCol.SelectedValueMemberPath = "UserId"; assignUserCol.DisplayMemberPath = "UserName"; this.leadsGv.Columns.Add(assignUserCol); ((GridViewComboBoxColumn)this.leadsGv.Columns["Assign User"]).ItemsSource = e.Result; usersDg.ItemsSource = e.Result; So this code populated the column ( no value is displayed by default ) but when I select a value, the value doesn't stick. The datagrid is not readonly.Looking at your code-snippet, I am not quite sure what are your exact settings ? Is the "UserId" Property a part of the ItemsSource of the grid or of the GridViewComboBoxColumn ?
Furthermore, in order to be able to provide you with a more accurate solution, I would need a bit more information about your application, more specifically about the two data sources - for the grid and for the column.
Maya
the Telerik team
The UserId property is part of the ItemSource of the combo box.
Both Data sources are returned by calls to webservices. The data source for the grid is basically a select on a database table but since the data needed for the combo box isn't an actual table in the database, I created a table in Visual Studio using the linq to sql designer. I then populated the object in my webserivces and returned the values to my silverlight app.
The data source schema for the combo box is as follows:
userid nvarchar(50)
UserName nvarchar(50).
I would like to select the username in the combo box.
To bind the combo box I just call the webservice that returned a list of the above object.
Firstly, you may take a look at this help article. It demonstrates the appropriate settings of the GridViewComboBoxColumn.
Basically, the data source for the grid and the column are two separate ones. The DataMemberBinding property of the column is supposed to be bound to a property from the ItemsSource of the grid. Thus its data-engine will know what it is supposed to be shown in that column. Following up the example in the documentation, the DataMemberBinding Property is set to "CountryId", which is a part of the RadGridView's source. Most commonly that property is of type integer.
Furthermore, the source of the column exposes two properties - "Id" and "Name". The "Id" is the one that connects the data from the GridViewComboBoxColumn's ItemsSource to the one of the grid. Thus, as "Fernando Alonso" has "CountryId" - 1, it will be connected to the item "Spain" in the column's source as its Id = 1. SelectedValueMemberPath Property represents the property, which connects the two sources, while the DisplayMemberPath holds the one that should visually appear in the column.
So, considering your application, you need to expose a property in the source of the grid that is associated to the one in the source of the column - UserId. Otherwise, the RadGridView will not be aware what should be saved as it does not contain a corresponding property.
Maya
the Telerik team