kahlua001
Well-known member
I have a problem I cant figure out. any help is appreciated!
I have a datalist whoses datasource is a custom type. In this type is a public member that is a generic list. So in the ItemDataBound event I have.
Now, the problem is that I am taking the datalists item template and loading from a usercontrol. So now, the ItemDataBound doesnt work becuase its outside of a datalist, so Ive read that I need to cast the Dataitem to a DataListItem like so..
Ive 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
I have a datalist whoses 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 datalists item template and loading from a usercontrol. So now, the ItemDataBound doesnt work becuase its outside of a datalist, so Ive read that I need to cast the Dataitem to a DataListItem like so..
Code:
<%# DataBinder.Eval(((DataListItem)Container).DataItem, "FirstName") %>
Ive 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