Inheriting from RepeaterItem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • wilkinsonr@gmail.com

    #1

    Inheriting from RepeaterItem

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

    public class MyRepeaterItem : System.Web.UI.W ebControls.Repe aterItem
    {
    public MyRepeaterItem( int itemIndex, ListItemType itemType) :
    base(itemIndex, itemType) {}
    public bool IsDataItem {
    get {
    return ((this.ItemType == ListItemType.It em) || (this.ItemType
    == ListItemType.Al ternatingItem)) ;
    }
    }

    public Image Images(string ID) {
    return (Image)FindCont rol(ID);
    }
    }

    and this is my code:

    protected void repFiles_ItemDa taBound(object sender,
    RepeaterItemEve ntArgs e) {
    MyRepeaterItem rep = (MyRepeaterItem )e.Item;

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

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

    All I want to do is add some helper functions to the RepeaterItem. Any
    helpp would be great.
    Thanks,
Working...