I have one RadComboBox. I fill it with a function which returns for example {Stack, Over, Flow, StackOverFlow} When I click RadCombobox that items are listed.
And I want to give first place for empty element.
And I tried to do below:
var stack= GetItems(SiteId);
RadComboBox1.Items.Add(new RadComboBoxItem("", "0"));
RadComboBox1.DataSource = stack;
RadComboBox1.DataTextField = "Name";
RadComboBox1.DataValueField = "Id";
RadComboBox1.DataBind();
RadComboBox1.AllowCustomText = false;
There is no change. Only {Stack, Over, Flow, StackOverFlow} are listed.
When I write below code
var stack= GetItems(SiteId);
RadComboBox1.DataSource = stack;
RadComboBox1.DataTextField = "Name";
RadComboBox1.DataValueField = "Id";
RadComboBox1.DataBind();
RadComboBox1.Items.Add(new RadComboBoxItem("xyz", "0"));
RadComboBox1.AllowCustomText = false;
Only {Stack, Over, Flow, StackOverFlow, xyz} are listed.
But I dont get the result which I want.
And the design side is below.
<telerik:RadComboBox ID="RadComboBox1" runat="server" Width="120px" MarkFirstMatch="true" Filter="Contains"></telerik:RadComboBox>
How can I do?
I want to list { " "
, "Stack"
, "Over"
, "Flow"
, "StackOverFlow"
}
Using your first choice, add RadComboBox1.AppendDataBoundItems = true
before you call DataBind()
. This means it won't clear out the existing items before adding the items from the data bind. You will need to manually clear the items beforehand if necessary:
RadComboBox1.Items.Clear();
RadComboBox1.ClearSelection();