views:

114

answers:

2

I'm currently using a certain ItemTemplate for three repeaters that are all on the same page, but they are all bound to different data sources. Is there any way to refactor my web form without using a user control to easily refer to this template so I will only have to define it once?

+2  A: 

No. That's the reason user controls exist, to encapsulate repeating visual components.

Oded
I don't quite agree. To me, user controls are their own "entities" which can be put just about anywhere and hold their own state, etc. What I was looking for was something similar to a macro.
Deniz Dogan
A: 

yes it's possible, create another asp.net control (ascx) that is having a repeater, create a public method that accepts data table (or list or items) and bind the repeater with that, you will probably get this done in 10mins


public void BindData(DataTable dt)
{
    rpt.DataSource = dt;
    rpt.DataBind();
}

It will work if your dt has same column names.

lakhlaniprashant.blogspot.com