473,322 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

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)
Nov 19 '05 #1
0 840

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: jason | last post by:
Is it possible to POST a FORM to multiple URLS at the same time....OR.... Is the only workaround for this scenario to use response.redirect in the called ASP page and do a multi processing? -...
7
by: Rui Pestana | last post by:
Hello all, I want to use the POST method to submit the form and then grab the parameters in the asp file with request.form("parm"). The problem is that I am using the _search target to open...
4
by: Phill | last post by:
I read in one of Jesse Liberty's books that: "Because ToString() is a virtual method in the base class Object, it is guaranteed to be available in every derived class." (P.179 Programming C#) ...
3
by: Martin Høst Normark | last post by:
Hi everyone I get a System.NullReferenceException performing this code: public void Item_Bound(object sender, DataListItemEventArgs e) { if((int)(e.Item.DataItem as DataRowView).Row != 0) {...
3
by: Ken Varn | last post by:
I am just starting the process of creating ASP.NET server controls. I have created controls for .NET applications, but have just started with ASP.NET. I am a little confused about some areas that...
2
by: Fred Flintstone | last post by:
What's the difference between these two methods? 1 - Parameterrized SQL queries: Dim CommandObject As New Data.SqlClient.SqlCommand With CommandObject .Connection = myConnection...
26
by: Patient Guy | last post by:
The code below shows the familiar way of restricting a function to be a method of a constructed object: function aConstructor(arg) { if (typeof(arg) == "undefined") return (null);...
7
by: Guillaume BRAUX | last post by:
Hello, I am looking for a way to create a method that will be available to other classes in my project, but without needing to instanciate the class. I don't want this method to be static (il...
19
by: zzw8206262001 | last post by:
Hi,I find a way to make javescript more like c++ or pyhon There is the sample code: function Father(self) //every contructor may have "self" argument { self=self?self:this; ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.