Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ItemCommand event of GridView or ListView

ItemCommand event of GridView or ListView

Scheduled Pinned Locked Moved ASP.NET
javascripthelpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 1033907
    wrote on last edited by
    #1

    GridView and ListView constrols have ItemCommand event where I can react to events generated by Button controls in the individual items. Is there a way to detect and handle events raised by non-Button controls (like CheckBox with AutoPostBack=true)? I spent several hours trying to do this but totally failed. Do you have any ideas? Any help appreciated.

    S 1 Reply Last reply
    0
    • M Member 1033907

      GridView and ListView constrols have ItemCommand event where I can react to events generated by Button controls in the individual items. Is there a way to detect and handle events raised by non-Button controls (like CheckBox with AutoPostBack=true)? I spent several hours trying to do this but totally failed. Do you have any ideas? Any help appreciated.

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      Member 1033907 wrote:

      Is there a way to detect and handle events raised by non-Button controls (like CheckBox with AutoPostBack=true)?

      Yes! You can track it in ItemCreated/RowCreated. Google for 'EventBubbling' and you will get links like these: http://www.dotnetspider.com/resources/30842-Raising-An-Event-From-CheckBox-In-A-GridView.aspx[^] http://msdn.microsoft.com/en-us/library/aa719644(VS.71).aspx[^]

      M 1 Reply Last reply
      0
      • S Sandeep Mewara

        Member 1033907 wrote:

        Is there a way to detect and handle events raised by non-Button controls (like CheckBox with AutoPostBack=true)?

        Yes! You can track it in ItemCreated/RowCreated. Google for 'EventBubbling' and you will get links like these: http://www.dotnetspider.com/resources/30842-Raising-An-Event-From-CheckBox-In-A-GridView.aspx[^] http://msdn.microsoft.com/en-us/library/aa719644(VS.71).aspx[^]

        M Offline
        M Offline
        Member 1033907
        wrote on last edited by
        #3

        Thanks for the reply. What exactly do you mean by using ItemCreated event in combination with event bubbling? I don't get it. I understand that I can create my own control derived from checkbox which, when checked, raises a bubble event which is then cought by the ListView. Is this what you meant? Otherwise, the first link you posted provides a fairly easy solution, without event bubbling at all.

        S 1 Reply Last reply
        0
        • M Member 1033907

          Thanks for the reply. What exactly do you mean by using ItemCreated event in combination with event bubbling? I don't get it. I understand that I can create my own control derived from checkbox which, when checked, raises a bubble event which is then cought by the ListView. Is this what you meant? Otherwise, the first link you posted provides a fairly easy solution, without event bubbling at all.

          S Offline
          S Offline
          Sandeep Mewara
          wrote on last edited by
          #4

          Member 1033907 wrote:

          Is this what you meant?

          No. In ItemCreated, find the control and attach the hanlder. Though as you already saw, other approach could be done easily. It's just that event methods needs to be public or protected.

          M 1 Reply Last reply
          0
          • S Sandeep Mewara

            Member 1033907 wrote:

            Is this what you meant?

            No. In ItemCreated, find the control and attach the hanlder. Though as you already saw, other approach could be done easily. It's just that event methods needs to be public or protected.

            M Offline
            M Offline
            Member 1033907
            wrote on last edited by
            #5

            So I attach the handler and in the handler, call the RaiseBubbleEvent? I'am afraid I still don't quite get it but it's more a matter of curiosity now, I can put together some working solution.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups