Reputation: 26227
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?
Upvotes: 6
Views: 1470
Reputation: 5806
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.
Upvotes: 1
Reputation: 498934
No. That's the reason user controls exist, to encapsulate repeating visual components.
Upvotes: 3