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

RadListControl - ItemDataBound Event

1 Answer 169 Views
ListControl
This is a migrated thread and some comments may be shown as answers.
Kim Bouchard
Top achievements
Rank 1
Kim Bouchard asked on 16 Jun 2010, 08:16 AM
Hi,

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
Kim

1 Answer, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 17 Jun 2010, 04:41 PM
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
    {
        get
        {
            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.

Regards,
Victor
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.
Tags
ListControl
Asked by
Kim Bouchard
Top achievements
Rank 1
Answers by
Victor
Telerik team
Share this question
or