Repeater OnItemCommand

P

Peter

Hi,

I have an <asp:Repeater> on my page. In the repeater I have
LinkButtons, which when clicked cause an "OnItemCommand" method to be
called.

In my "OnItemCommand" method, I notice that the e.Item.DataItem
property is null. Is this normal? Is it possible to have this property
return the original DataItem which has used when popultaing the
Repeater control? (I can see that the DataItem is set as I expected on
OnItemDataBound, but not in the OnItemCommand).

Thanks,
Peter

--
 
P

Peter

Nathan said:
In what event do you do the call the DataBind() method?

I call it from within Page_Load.

From Page_Load I fetch some data from a "data access" class which I set
as the DataSource for the repeater, and then I call DataBind.

If I have a "ItemDataBound" method, I can see the individual DataItem
objects, but I can not see them when the "ItemCommand" method is called.

Thanks,
Peter
 
N

Nathan Sokalski

The DataItem property is not available in the ItemCommand event, it is
simply there because it is a property of Item. I normally recommend using
e.CommandArgument in ItemCommand.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top