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

Custom text when item is highlighted with up/down arrows

1 Answer 51 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
chris_cf
Top achievements
Rank 2
chris_cf asked on 27 Apr 2012, 03:17 AM
I have some custom text that I am displaying in a radcombobox based on the following template:

<ItemTemplate>
  US
  <%# DataBinder.Eval(Container.DataItem, "AmountUSD", "{0:$####}")%>
  =
  <%# DataBinder.Eval(Container.DataItem, "Code") %>
  <%# DataBinder.Eval(Container.DataItem, "AmountLocal", "{0:$####}") %>
</ItemTemplate>

However, when an item is highlighted with the up/down arrows, the DataTextField (AmountUSD) value shows. For example, the combobox item will show "US $20 = EC $54" in the list, but when highlighted, the combobox text will show "20.0000".

I would like to either have the combobox text show as the template text or not show at all.

This custom text is already stored in an attribute called "DisplayText". Is there a way to use that?

1 Answer, 1 is accepted

Sort by
0
chris_cf
Top achievements
Rank 2
answered on 27 Apr 2012, 03:38 AM
Solved this by setting the item text in the ItemDataBound event:

protected void comboTopUpAmount_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
        {
            TopUpAmountListView t = (TopUpAmountListView)e.Item.DataItem;
            string displayText = String.Format("US {0} = {1} {2}",
                String.Format("{0:$####}", t.AmountUSD),
                t.Code,
                String.Format("{0:$####}", t.AmountLocal));
 
            e.Item.Attributes["DisplayText"] = displayText;
            e.Item.Text = displayText;
        }
Tags
ComboBox
Asked by
chris_cf
Top achievements
Rank 2
Answers by
chris_cf
Top achievements
Rank 2
Share this question
or