ImageButton, Repeater and ItemDataBound

  • Thread starter RicercatoreSbadato
  • Start date
R

RicercatoreSbadato

I've put an ImageButton control in a repeater.
I've set the 'OnItemBound' event of the repeater.

Why when I click on the ImageButton it doesn't work?
What else I have to do ?
 
M

Mark Fitzpatrick

Did you wire up the button? You use events such as the OnItemBound to wire
up the controls yourself. In the code for your OnItemBound event, you'll
need to first find the control, then set the appropriate event handler for
the Image Button event that you want it to handle. Usually in a repeater
scenario I use the command event that way I can set a commandargument and
commandname with a value relevant to the record. Some code may look like

(ImageButton) myButton = (ImageButton)e.Item.FindControl("myButton");
myButton.Command = ((DbDataRecord)e.Item.DataItem).GetString(0);
myButton.CommandArgument = ((DbDataRecord)e.Item.DataItem).GetString(1);

myButton.Command += my command event handler
 

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,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top