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

Accessing object datasource object on item create

1 Answer 55 Views
ListView
This is a migrated thread and some comments may be shown as answers.
maurice
Top achievements
Rank 1
maurice asked on 06 Oct 2011, 07:34 AM
I have a radlistview that is binding to a object datasource, I cannot find out how to access that Object when the event on item created it fired off. Can anyone help. be at this for a few hours.

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 10 Oct 2011, 04:12 AM
Hi Maurice,

You cannot access the desired object on ItemCreated as the item is not bound at that time. You can try the ItemDataBound event instead. There try the following code:

protected void RadListView1_ItemDataBound(object sender, RadListViewItemEventArgs e)
{
    if(e.Item is RadListViewDataItem)
    {
        MyCustomObject obj = e.Item.DataItem as MyCustomObject;
    }
}

Please replace the MyCustomObject with the name of your custo Object.

Best wishes,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
ListView
Asked by
maurice
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or