DataGrid Cell with Image Button In It

Discussion in 'ASP .Net Datagrid Control' started by KJ, Dec 15, 2003.

  1. KJ

    KJ Guest

    I create a datagrid and at runtime I add an ImageButton to certain
    cells(e.Item.Cells.Controls.Add(imgbutton)). Now when I click on a row
    that contain an image button, in the ItemCommand event the row is
    return.

    So I do e.Item.Cells(3) is the cell with the control in it supposely.
    When I do e.Item.Cells.Controls.Count it returns 0. Why? How can I
    tell if I clicked on a row with an imagebutton in cell 3?

    Thanks
    KJ, Dec 15, 2003
    #1
    1. Advertising

  2. Yes, you have to use CommandName or Command Argument.
    Eg.

    C#

    ImageButton btn = new ImageButton();
    btn.CommandName = "xx";

    protected void myItemCommand(...)
    {
    if(e.CommandName == "xx")
    {
    // your code
    }
    }

    --
    The Best Regards,
    ..Net Developer
    Michael Tkachev
    "KJ" <> wrote in message
    news:...
    > I create a datagrid and at runtime I add an ImageButton to certain
    > cells(e.Item.Cells.Controls.Add(imgbutton)). Now when I click on a row
    > that contain an image button, in the ItemCommand event the row is
    > return.
    >
    > So I do e.Item.Cells(3) is the cell with the control in it supposely.
    > When I do e.Item.Cells.Controls.Count it returns 0. Why? How can I
    > tell if I clicked on a row with an imagebutton in cell 3?
    >
    > Thanks
    Micharel Tkachev, Dec 16, 2003
    #2
    1. Advertising

  3. KJ

    KJ Guest

    That works if you are clicking on the image in the row but I actually
    have 2 imagebutton in the row. One I click on and another that I add
    if a certain condition is met. I can tell which row is clicked but I
    need to find out if the other imagebutton is contained in the row.










    "Micharel Tkachev" <> wrote in message news:<>...
    > Yes, you have to use CommandName or Command Argument.
    > Eg.
    >
    > C#
    >
    > ImageButton btn = new ImageButton();
    > btn.CommandName = "xx";
    >
    > protected void myItemCommand(...)
    > {
    > if(e.CommandName == "xx")
    > {
    > // your code
    > }
    > }
    >
    > --
    > The Best Regards,
    > .Net Developer
    > Michael Tkachev
    > "KJ" <> wrote in message
    > news:...
    > > I create a datagrid and at runtime I add an ImageButton to certain
    > > cells(e.Item.Cells.Controls.Add(imgbutton)). Now when I click on a row
    > > that contain an image button, in the ItemCommand event the row is
    > > return.
    > >
    > > So I do e.Item.Cells(3) is the cell with the control in it supposely.
    > > When I do e.Item.Cells.Controls.Count it returns 0. Why? How can I
    > > tell if I clicked on a row with an imagebutton in cell 3?
    > >
    > > Thanks
    KJ, Dec 16, 2003
    #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. news.rcn.com
    Replies:
    1
    Views:
    9,618
    Chris Smith
    Jul 12, 2004
  2. Phillip Roncoroni
    Replies:
    14
    Views:
    1,060
    Toby A Inkster
    Apr 5, 2004
  3. active
    Replies:
    15
    Views:
    715
    active
    Jun 27, 2007
  4. Empire City
    Replies:
    3
    Views:
    384
    Empire City
    Apr 30, 2004
  5. RJ
    Replies:
    1
    Views:
    223
    Eliyahu Goldin
    Feb 17, 2005
Loading...

Share This Page