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

Pass NeedDataSource Event out from User Control

2 Answers 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephanie
Top achievements
Rank 1
Stephanie asked on 11 Aug 2008, 11:19 AM
I've created a custom user control with a RadGrid in the control. I have several search results pages that get their data in different types of searches and end up on different pages, but the RadGrid displays the same fields and has the same actions, so instead of just copying functionality to a million places, I figured I'd create a user control and then just drop that user control on the pages.

Anyway, I need the actual code that is run in the NeedDataSource event to be called in the page including the User Control, not in the user control itself. So when the RadGrid needs a datasource, it fires the event, and that somehow fires another event to the page, the datasource is set, and then bound to the grid.

I'm not new to programming, but I am new to .NET and I'm not quite sure how to do this. I've read a little bit on OnBubbleEvent etc, but I don't quite understand how to make that work in this situation.

Edit: I'm using Visual Studio 2008 and C# as my programming language.

Any help would be greatly appreciated,
Stephanie

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Aug 2008, 12:20 PM
Hello Stephanie,

Can you check if you have set the same namespace in the code behind and in the aspx? If not, please try setting the namespace as shown below.
cs:
using Telerik.Web.UI; 

aspx:
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 

Thanks
Princy.

0
Stephanie
Top achievements
Rank 1
answered on 12 Aug 2008, 09:42 AM
I'm sorry, I'm not sure what that has to do with my issue. I'm not having trouble using the RadGrid. It is working fine when I use it in a page. I'm asking how, when putting a RadGrid in a custom user control, I can have the NeedDataSource event be handled by the page including the custom user control, instead of in the user control itself.

Maybe I didn't explain it well enough, sorry, I'm not quite sure the correct terminology to use.

Cheers,
Stephanie
Tags
Grid
Asked by
Stephanie
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Stephanie
Top achievements
Rank 1
Share this question
or