Custom text when item is highlighted with up/down arrows

2 posts, 0 answers
  1. chris_cf
    chris_cf avatar
    53 posts
    Member since:
    Jul 2007

    Posted 26 Apr 2012 Link to this post

    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?
  2. chris_cf
    chris_cf avatar
    53 posts
    Member since:
    Jul 2007

    Posted 26 Apr 2012 Link to this post

    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;
            }
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top