开发者

radListview telerik accessing object on server side binding

开发者 https://www.devze.com 2023-04-11 06:35 出处:网络
I have a object datasource for a telerik listview and on the onitemcreated method I want to be able to pul开发者_StackOverflow中文版l out that current object that it is on. can anyone help me? ThanksY

I have a object datasource for a telerik listview and on the onitemcreated method I want to be able to pul开发者_StackOverflow中文版l out that current object that it is on. can anyone help me? Thanks


You cannot access the data object in OnItemCreated because that occurs before any data binding occurs. Instead, you should do you processing in OnItemDataBound. You can use logic like this:

var listDataItem = e.Item as RadListViewDataItem;
if (listDataItem != null)
{
    var theData = listDataItem.DataItem;
    //...
}

Telerik has a page in their documentation specifically addressing the differences between the ItemCreated and ItemDataBound events. Here is a snippet of that:

ItemCreated is fired before the item is data-bound. Thus no data is still in the listview item or the controls nested inside it. In ItemDataBound all is available.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号