Binding an arraylist to a datalist

N

npverni

I have datalist binding to an arraylist of custom objects (defined in a
class "PageItem"). What I am trying to do is access the source
PageItem object in an ItemCommand event handler of the DataList.


For example, I would like to do something like the following:


protected void dlPages_ItemCommand(object source,
DataListCommandEventArgs e)
{
(PageItem) thisPage = (PageItem)[...?? reference to the object
that this item is bound to...]
}



Thanks,

Nathan
 
K

Karl Seguin [MVP]

PageItem pageItem = (PageItem)e.Item.DataItem;

you'll want to make sure e.Item.ItemType is an Item or an AlternatingItem
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,125
Latest member
VinayKumar Nevatia_
Top