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

Programmatically Wireing Event handler on a loaded control.

2 Answers 114 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 16 Dec 2009, 06:23 PM
Good Afternoon,

I am trying to wire up the ItemDataBound event of the RadListView control and encountering issues doing so. Let me describe the situation.

I am building a custom Sharepoint webpart that loads a control from an aspx page using Page.LoadControl. The loaded aspx page contains the RadListViewControl whose events I wish to wire up.
_ctrlGoogleCalendarSubscriptions = Page.LoadControl("/_controltemplates/NUGoogleCalendarSubscriptions.ascx");  
 

To wire up the event I call;

 

 

 

_radCalendarListView.ItemDataBound += new EventHandler(this.radCalendarListView_OnItemDataBound);  
 

I do this in the CreateChildControls method.

 

 

However when I compile I recieve the error "No overload for 'radCalendarListView_OnItemDataBound' matches delegate 'System.EventHandler'"

The method I am passing is below,

 

        protected void radCalendarListView_OnItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)  
        {  
        } 

I am able to wire up the DataBinding event without issue.

Am I missing something, is this not possible with the Rad Controls when loaded in this fashion?

Please let me know if you need any further details at all.

Regards,

Christian Brown

2 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 17 Dec 2009, 01:42 PM
Hello Christian,

The delegate for the ItemDataBound handler of RadListView has difference signature, hence you can intercept that event programmatically in the following way:

_radCalendarListView.ItemDataBound+=new EventHandler<RadListViewItemEventArgs>(_radCalendarListView_ItemDataBound);

I would also recommend you avoid using ids starting with underscores for your controls.
 
Best regards,
Sebastian
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Christian
Top achievements
Rank 1
answered on 17 Dec 2009, 08:01 PM
Much Appreciated Sebastian,

I'd just realized that the signature was odd this morning when I actually looked at the Intellisense instead of simply working by rote. This did the trick.

Regards,

Christian
Tags
General Discussions
Asked by
Christian
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Christian
Top achievements
Rank 1
Share this question
or