How do I cast something as a user control?
From: Alan Silver (alan-silver_at_nospam.thanx)
Date: 02/22/05
- Next message: Tampa.NET Koder: "Re: Images"
- Previous message: Alan Silver: "Re: How do I do data binding with a checkbox?"
- Next in thread: Scott Allen: "Re: How do I cast something as a user control?"
- Reply: Scott Allen: "Re: How do I cast something as a user control?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 22 Feb 2005 19:52:46 +0000
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
-- Alan Silver (anything added below this line is nothing to do with me)
- Next message: Tampa.NET Koder: "Re: Images"
- Previous message: Alan Silver: "Re: How do I do data binding with a checkbox?"
- Next in thread: Scott Allen: "Re: How do I cast something as a user control?"
- Reply: Scott Allen: "Re: How do I cast something as a user control?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|