DataListItem casting error

kahlua001

Contributor
Joined
Dec 15, 2003
Messages
507
Location
los angeles
I have a problem I cant figure out. any help is appreciated!

I have a datalist whose's datasource is a custom type. In this type is a public member that is a generic list. So in the ItemDataBound event I have.

Code:
PostType Post = ((PostUserBookmarkType)e.Item.DataItem).Post;

lnkName.Text = Post.Name;

Now, the problem is that I am taking the datalist's item template and loading from a usercontrol. So now, the ItemDataBound doesnt work becuase its outside of a datalist, so I've read that I need to cast the Dataitem to a DataListItem like so..

Code:
<%# DataBinder.Eval(((DataListItem)Container).DataItem, "FirstName") %>

I've tried different variations to cast my PostType to a DataListItem but get invalid casting errors. Anybody know the correct way to take my 1st line of code and cast that to a DataListItem which gets casted to my custom type??

Thanks
 
Back
Top