ImageButton, Repeater and ItemDataBound

  • Thread starter Thread starter RicercatoreSbadato
  • Start date 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 ?
 
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
 
Back
Top