DataList OnItemDataBound

Discussion in 'ASP .Net Web Controls' started by Jeremy, Jul 9, 2004.

  1. Jeremy

    Jeremy Guest

    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
     
    Jeremy, Jul 9, 2004
    #1
    1. Advertising

  2. Jeremy

    Jos Guest

    Jeremy wrote:
    > 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 + ')');

    --

    Jos
     
    Jos, Jul 9, 2004
    #2
    1. Advertising

  3. Jeremy

    Jeremy Guest

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

    Thanks for your help
    Jeremy

    "Jos" <> wrote in message
    news:%...
    > Jeremy wrote:
    > > 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 + ')');
    >
    > --
    >
    > Jos
    >
    >
    >
     
    Jeremy, Jul 9, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Antonio D'Ottavio
    Replies:
    1
    Views:
    2,739
    Antonio D'Ottavio
    Sep 19, 2005
  2. Steven
    Replies:
    1
    Views:
    1,660
    Simon
    Jul 9, 2003
  3. Nevyn Twyll
    Replies:
    8
    Views:
    1,940
  4. MattB

    datalist and OnItemDatabound

    MattB, Mar 28, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    3,997
    MattB
    Mar 29, 2005
  5. Joey
    Replies:
    0
    Views:
    145
Loading...

Share This Page