468,115 Members | 2,068 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,115 developers. It's quick & easy.

Inheriting from RepeaterItem

Hi All,
I'm having a metal blank. This is my class:

public class MyRepeaterItem : System.Web.UI.WebControls.RepeaterItem
{
public MyRepeaterItem(int itemIndex, ListItemType itemType) :
base(itemIndex, itemType) {}
public bool IsDataItem {
get {
return ((this.ItemType == ListItemType.Item) || (this.ItemType
== ListItemType.AlternatingItem));
}
}

public Image Images(string ID) {
return (Image)FindControl(ID);
}
}

and this is my code:

protected void repFiles_ItemDataBound(object sender,
RepeaterItemEventArgs e) {
MyRepeaterItem rep = (MyRepeaterItem)e.Item;

if (rep.IsDataItem) {
rep.Images("icon").ImageUrl = "icons/testing.jpg";
}
}

and I get the error "Unable to cast object of type
'System.Web.UI.WebControls.RepeaterItem' to type 'MyRepeaterItem'."

All I want to do is add some helper functions to the RepeaterItem. Any
helpp would be great.
Thanks,
Oct 29 '08 #1
0 1017

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by richardlane | last post: by
11 posts views Thread by Noah Coad [MVP .NET/C#] | last post: by
2 posts views Thread by ric carrasquilla | last post: by
3 posts views Thread by louise raisbeck | last post: by
2 posts views Thread by Charles Law | last post: by
3 posts views Thread by Alex Satrapa | last post: by
3 posts views Thread by champ.supernova | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.