RadListControl - ItemDataBound Event

2 posts, 0 answers
  1. Kim Bouchard
    Kim Bouchard avatar
    13 posts
    Member since:
    Sep 2007

    Posted 16 Jun 2010 Link to this post


    i am currently evaluating the Q2 2010 Beta and it's new RadListControl.
    Now i've got a little problem with the ItemDataBound Event.

    My scenario is
    Target FRamework 4.0
    RadListControl is bound to a BindingSource.
    BindingSource is bound to a Entity Framework ObjectResult<T>.

    By the way in Q1 2010 Sp2 everthing works as expected.

    In the ItemDataBound Event i try to customize the displayed Text of each item.
    The text should be build up by 2 Fields of the DataItem.
    But there seems to be no more DataItem Object in the event args ???.

    How can i achieve that with the new ListItemDataBoundEventArgs ?

    Kind Regards
  2. Victor
    Victor avatar
    1358 posts

    Posted 17 Jun 2010 Link to this post

    Hello Kim Bouchard,

    Thank you for writing.

    It is puzzling that you do not have a data item in these event args. Here is how the ListItemDataBoundEventArgs class looks like:
    public class ListItemDataBoundEventArgs : EventArgs
        private RadListDataItem newItem = null;
        public ListItemDataBoundEventArgs(RadListDataItem newItem)
            this.newItem = newItem;
        public RadListDataItem NewItem
                return this.newItem;
    Also we have unit tests that change properties of the bound RadListDataItem.
    If you manage to set the Text property however, you will encounter an exception. We initially thought of forbidding the users to set the text for data bound items since the text is being provided by the binding logic, and if users want to change how the data item is visually presented they can use the VisualItemFormatting event in which they can set the text to the visual item instead. Later, however, we decided that users should also be able to modify data items in the data bound item as well so this functionality will be available in the final release.

    Here is how the ItemDataBound event handler looks like taken directly from our unit tests:
    int counter = 0;
    this.testListBox.ItemDataBound += (sender, args) =>
        args.NewItem.Text = counter++.ToString();
    Please write again if you have other questions.

    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top