Need to change image of imagebutton in datagrid template column

Discussion in 'ASP .Net Datagrid Control' started by jef, Apr 9, 2005.

  1. jef

    jef Guest

    I'm going nuts.. I've got a template column with an imagebutton in it.
    I would like to change the image on the button when the button is
    clicked. However, in the _ItemCommand() function I can't seem to
    figure out how to get a reference to the imagebutton object. Help
    anyone?
     
    jef, Apr 9, 2005
    #1
    1. Advertising

  2. jef

    Brock Allen Guest

    In the ItemCommand, take the ItemCommandEventArgs and do a ItemCommandEventArgs.Item.FindControl("IDOfYourImageCtrl")
    and cast it to a ImageButton. Then you'll be able to work with it.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > I'm going nuts.. I've got a template column with an imagebutton in it.
    > I would like to change the image on the button when the button is
    > clicked. However, in the _ItemCommand() function I can't seem to
    > figure out how to get a reference to the imagebutton object. Help
    > anyone?
    >
     
    Brock Allen, Apr 9, 2005
    #2
    1. Advertising

  3. jef

    jef Guest

    Thanks... that works fine. That said, does anyone know how to do the
    same thing only with client-side code? Seeing that I don't know the
    name of the control inside the template column, I'm not sure how I
    would reference it in Javascript.
     
    jef, Apr 11, 2005
    #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. EMW
    Replies:
    0
    Views:
    455
  2. MattB
    Replies:
    1
    Views:
    3,879
    =?Utf-8?B?RWx0b24gVw==?=
    Apr 18, 2005
  3. Austin Bailey

    Template Column with ImageButton in it

    Austin Bailey, Jul 29, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    119
    Austin Bailey
    Jul 29, 2003
  4. KJ
    Replies:
    2
    Views:
    205
    Stevie_mac
    Aug 16, 2003
  5. Wenceslao Leon

    ImageButton in template column in edit mode don't fire event

    Wenceslao Leon, Sep 13, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    152
    Wenceslao Leon
    Sep 13, 2003
Loading...

Share This Page