DataList OnItemDataBound

J

Jeremy

Hi,

Hope someone can help

I have a datalist and in each <TD> i have an image which is based off a
Field Value. What I require is when the user clicks the <TD> the images
cycle through a predefined set.

I cannot have this postback as there would be approx 80 <TD> on the page and
they need to be able to fill the sheet out quickly.

So I tried the following (Delphi .NET Code)

procedure TMark.OnItemDataBound(Sender : TObject;E: DataListItemEventArgs);
begin
e.Item.Attributes.Add('onclick','cycleImages("id of the image to be
cycled")');
end;


Two Problems.
1. No javascript appears in the output
2. How do I get the uniqueID of the Image so the javascript can find it.

Any Ideas on how to accomplish this. Basically I need a user to fill out the
sheet by clicking on the cells and once finished hit a save button that will
postback and update the database.

Thanks
Jeremy
 
J

Jos

Jeremy said:
Hi,

Hope someone can help

I have a datalist and in each <TD> i have an image which is based off
a Field Value. What I require is when the user clicks the <TD> the
images cycle through a predefined set.

I cannot have this postback as there would be approx 80 <TD> on the
page and they need to be able to fill the sheet out quickly.

So I tried the following (Delphi .NET Code)

procedure TMark.OnItemDataBound(Sender : TObject;E:
DataListItemEventArgs); begin
e.Item.Attributes.Add('onclick','cycleImages("id of the image to be
cycled")');
end;


Two Problems.
1. No javascript appears in the output

No idea. Your code seems OK.
2. How do I get the uniqueID of the Image so the javascript can
find it.

myImage.ClientID
This is server-side, so you should use something like:
e.Item.Attributes.Add('onclick','cycleImages(' + myImage.ClientID + ')');
 
J

Jeremy

As soon as I moved the javascript to the image tag all was ok.

Thanks for your help
Jeremy
 

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,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top