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

Display null value

1 Answer 122 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
jbaird
Top achievements
Rank 1
jbaird asked on 21 Apr 2009, 11:37 AM

I am trying to bind a null foreign key to a specific value in the combo box itemssource.  Below is the relevant code.  Do you have any suggestions on how to make this display "None" instead of remaining blank?
 

/// <summary>

/// Event handler

/// </summary>

private void ClientBiz_OnDataListRefreshed(object sender, ClientBizNew.DataListRefreshedEventArgs e)

{

    //Get the xml and clear the respective list.

    string xml = this.ClientBiz.GetDataListResult(e.ServiceName, e.QueryName);

    if (!string.IsNullOrEmpty(xml))

    {

        XDocument xd = XDocument.Parse(xml);

 

if (e.ServiceName.Equals("GLChart"))

            {

                _chartList.Clear();

                _chartList.Add(new GLChartObject() { GLChartKey = null, GLChartName = "None" });

            }

 

 

            //get the xml nodes

            var nodes = from x in xd.Descendants(e.ServiceName) select x;

 

            //set the properties in the corresponding data class

            foreach (var n in nodes)

            {

                if (e.ServiceName.Equals("GLChart") && e.QueryName.Equals("GETALL"))

                {

                    int key = Convert.ToInt32(n.Element("PK_GLChart").Value);

                    string name = n.Element("ChartName").Value;

 

                    _chartList.Add(new GLChartObject() { GLChartKey = key, GLChartName = name });

 

                }

            }

 

 

            //set the binding of the respective combo box to the list.

            if (e.ServiceName.Equals("GLChart"))

            {

                this.cboChartOfAccounts.ItemsSource = _chartList;

            }

        }

    }
}

 

public class GLChartObject

{

    public int? GLChartKey { get; set; }

    public string GLChartName { get; set; }

}

 

<bfgs:RadComboBox x:Name="cboChartOfAccounts"

                  DisplayMemberPath="GLChartName"

                  SelectedValue="{Binding FK_GLChart, Mode=TwoWay}"

                  SelectedValuePath="GLChartKey"

                  FilteringMode="StartsWith"

                  Grid.Row="1"

                  Grid.Column="1"

                  Margin="2,2,2,2"

                  Height="22"

                  VerticalAlignment="Top"

                  TabIndex="6"/>

Thanks for your help.

1 Answer, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 21 Apr 2009, 03:44 PM
Hello jbaird,

I am afraid that the officially released version of RadComboBox (2009 SP1) has a bug that breaks scenarios like yours. I managed to fix it and I will be able to send you the new assemblies + sample application tomorrow (the build needs to be tested). Since this is a forum post, I am allowed to attach only trial assemblies here. Please, open a new support ticket if you want the developer assemblies (without trial check).

Regards,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ComboBox
Asked by
jbaird
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or