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

Reporting.List ItemDataBound event

2 Answers 418 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
peter
Top achievements
Rank 1
peter asked on 30 Nov 2009, 04:37 PM
Hi!

I have in my reporting project a Reporting.List (mainList) inside of another Reporting.List (secondList).

So when i databind the mainList, i also want to databind the secondList during the mainList ItemDataBound event based on the contents of the binded data.

For that i will need to access a class object during the ItemDataBound event of the MainList.

I was trying to do this:

        private void lstGrupoQuestoes_ItemDataBound(object sender, EventArgs e)
        {
            MyClass classobj = (MyClass)e.Item.DataItem;
            secondList.DataSource = classobj.subclassmethod;   //subclassmethod is a IList of another class object
            MyRepeater.DataBind()

       }
      
Unfortunely the EventArgs of the Reporting.List does not supports the "e.Item.DataItem". So how can i access a class object during the itemdatabound event?

Thanks.

2 Answers, 1 is accepted

Sort by
0
peter
Top achievements
Rank 1
answered on 02 Dec 2009, 12:00 PM
After some research i found what should be the answer to my question here:
http://www.telerik.com/support/kb/reporting/general/dataitem-replaced-by-dataobject.aspx

So my code is implemented this way:

 private void listXPTO_NeedDataSource(object sender, EventArgs e) 
 { 
     (...)
     listXPTO.DataSource = myObjClass
 } 
 
 
 private void listXPTO_ItemDataBound(object sender, EventArgs e) 
 { 
     Telerik.Reporting.Processing.ReportItemBase item = Telerik.Reporting.Processing.ReportItemBase)sender; 
             
     MyClass objmyclass = (MyClass)item.DataObject.RawData; 
      
 } 


The problem is that in the ItemdataBound event e cant access my class object because the "item.DataObject.RawData" comes null.


During the NeedDataSource event  the myObjClass comes fully assigned with contents to the listXPTO datasource.



So why the RawData comes null?









0
Jhony Malta
Top achievements
Rank 1
answered on 15 Dec 2009, 06:49 PM
Hi! I had the same problem like you, but seeing your post and the link of the article that you supply, i tried the steps on that article and works to me.
Inspecting your example code, it seems to me that you had assigned the itemdatabou event to the list and not to the panel that contains it. I had attached that event to the panel and there i had access to the rowdata. Try it. ;)
Tags
General Discussions
Asked by
peter
Top achievements
Rank 1
Answers by
peter
Top achievements
Rank 1
Jhony Malta
Top achievements
Rank 1
Share this question
or