A
Alan Silver
hello,
If I capture the OnItemDataBound event for a repeater, datalist, etc, I
can get hold of a control in the ItemTemplate like this ...
Literal litFred = (Literal)e.Item.FindControl("litFred");
How do I do this when the ItemTemplate contains a user control? Say I
have created a control, and I add a page directive ...
<%@ Register TagPrefix="MyControls" TagName="Fred" Src="Fred.ascx" %>
I can create the control like this ...
<MyControls:Fred ID="fred" ... />
How do I get hold of this in the OnItemDataBound event? I can't do ...
Fred litFred = (Fred)e.Item.FindControl("litFred");
as this generates an error. Nor can I do ...
MyControls:Fred litFred =
(MyControls:Fred)e.Item.FindControl("litFred");
I even tried ...
MyControls.Fred litFred =
(MyControls.Fred)e.Item.FindControl("litFred");
But that didn't work either.
So, I've tried everything I can think of, please will someone put me out
of my misery and tell me how to do it ;-)
TIA
If I capture the OnItemDataBound event for a repeater, datalist, etc, I
can get hold of a control in the ItemTemplate like this ...
Literal litFred = (Literal)e.Item.FindControl("litFred");
How do I do this when the ItemTemplate contains a user control? Say I
have created a control, and I add a page directive ...
<%@ Register TagPrefix="MyControls" TagName="Fred" Src="Fred.ascx" %>
I can create the control like this ...
<MyControls:Fred ID="fred" ... />
How do I get hold of this in the OnItemDataBound event? I can't do ...
Fred litFred = (Fred)e.Item.FindControl("litFred");
as this generates an error. Nor can I do ...
MyControls:Fred litFred =
(MyControls:Fred)e.Item.FindControl("litFred");
I even tried ...
MyControls.Fred litFred =
(MyControls.Fred)e.Item.FindControl("litFred");
But that didn't work either.
So, I've tried everything I can think of, please will someone put me out
of my misery and tell me how to do it ;-)
TIA