Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

 

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..

 

<%# 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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...