Accessing object datasource object on item create

2 posts, 0 answers
  1. maurice
    maurice avatar
    8 posts
    Member since:
    Aug 2010

    Posted 06 Oct 2011 Link to this post

    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.
  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 09 Oct 2011 Link to this post

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