PC Review


Reply
Thread Tools Rate Thread

Can I have one method that will take either a RepeaterItemEventArgs or DataListItemEventArgs?

 
 
Alan Silver
Guest
Posts: n/a
 
      11th Aug 2005
Hello,

I am writing the code-behind for a user control that may have either a
Repeater or a DataList (depending on which .ascx file calls the
code-behind). I have put an DataItemBound event for each of these two
controls, and wrapped the DataBind() method in a try/catch block, so if
the .ascx that called the code doesn't have one, the code will still
continue.

All's well so far, but I have some complex code in the DataItemBound
event handler that needs to be the same for both controls. I would like
to move it into a separate method that can be called from either event
handler.

The problem is that the Repeater control gets a RepeaterItemEventArgs
object passed to its event and a DataList gets a DataListItemEventArgs
object. I would like to have a method that can accept either, and deal
with them in exactly the same way.

I thought of declaring the method with a parameter of EventArgs (from
which both other objects are derived), but this didn't work as this
doesn't contain the Item object which is needed.

Anyone any ideas how I handle this? It seems poor coding to have two
identical methods, other than the type of the single parameter passed,
but I can't see how to avoid it.

TIA

--
Alan Silver
(anything added below this line is nothing to do with me)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Method Signature For A Method That Can Return Objects and PrimitiveData Types... Sunburned Surveyor Microsoft C# .NET 15 21st Dec 2007 06:59 PM
ObjectDataSource & FormView adding two extra paramaters to Update method giving error non-generic method ... Fred Dag Microsoft ASP .NET 0 18th Sep 2006 11:36 PM
ObjectDataSource & FormView adding two extra paramaters to Update method giving error non-generic method ... Fred Dag Microsoft ADO .NET 0 18th Sep 2006 05:24 AM
Consuming webservices from a smart device project ... <Method>Async() web method calls missing in the reference.cs ... Rodrigus Makon Microsoft Dot NET Compact Framework 5 20th May 2006 09:04 AM
class method verses static method: whats the difference? Taylor Microsoft C# .NET 1 15th Nov 2003 06:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:34 PM.