Professional Web Applications Themes

DataGrid Cell with Image Button In It - ASP.NET Data Grid Control

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...

  1. #1

    Default DataGrid Cell with Image Button In It

    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 Guest

  2. #2

    Default Re: DataGrid Cell with Image Button In It

    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" <klj_mcsdhotmail.com> wrote in message
    news:d83a9214.0312151331.3f70a4b6posting.google.c om...
    > 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 Guest

  3. #3

    Default Re: DataGrid Cell with Image Button In It

    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" <m_tkachevhotmail.com> wrote in message news:<eoHhxt6wDHA.3116tk2msftngp13.phx.gbl>...
    > 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" <klj_mcsdhotmail.com> wrote in message
    > news:d83a9214.0312151331.3f70a4b6posting.google.c om...
    > > 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 Guest

Similar Threads

  1. Replies: 1
    Last Post: February 17th, 09:37 PM
  2. Binding a image button to a datagrid
    By herman in forum ASP.NET Data Grid Control
    Replies: 3
    Last Post: October 8th, 09:05 AM
  3. Replies: 3
    Last Post: April 30th, 12:19 AM
  4. Adding image button to a datagrid in execution time
    By Andrés Giraldo in forum ASP.NET Building Controls
    Replies: 0
    Last Post: September 18th, 05:12 PM
  5. Image Button in Datagrid WebControl
    By Alvin Bruney in forum ASP.NET Data Grid Control
    Replies: 7
    Last Post: August 23rd, 04:33 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139