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. How to avoid postback wheh click ImageButton to show/hide Gridview rows

How to avoid postback wheh click ImageButton to show/hide Gridview rows

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-nethelptutorial
14 Posts 5 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.
  • A Andraw111

    Hi, all, I use Asp.net 2.0. I create a ImageButton in a gridview row with category ID, when click it I will call function to show or hide all the rows with the same category ID, everything works fine. But the problem is that every time the button is click, the postback is called, how can I stop that? or have any better way to achieve my purpose, Thanks a lot.

    S Offline
    S Offline
    Sandesh M Patil
    wrote on last edited by
    #4

    use Ajax update panel and place your Image button in it.. :)

    1 Reply Last reply
    0
    • B Brij

      Are you calling a javascript function to show hide the rows, if yyes just return fasle from that javascript function

      Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

      A Offline
      A Offline
      Andraw111
      wrote on last edited by
      #5

      Hi, Brij. Thank you for your reply. When click button I call a function in .cs file. Can I avlid postback if use this way? I also search internet and try to user javascript to solve it, but failed. To access gridview row information like the following, I put it in block. But this doesn't work, get error "Object Required" in line: rows = document.getElementById(gridName).rows; also ask a silly question, since the javascript block is inside <head runat = "server"> </head>, it will executed in server side or client side? Thanks</x-turndown>

      B 1 Reply Last reply
      0
      • A Abhijit Jana

        What you can do, you can use Template Field to place ImageButton With in a AJAX Update Panel.

        Cheers ! Abhijit Jana | MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

        A Offline
        A Offline
        Andraw111
        wrote on last edited by
        #6

        Thanks, I am new to Asp.net, if I use Ajax, do I need to import some new library or third party tool? Basically it

        1 Reply Last reply
        0
        • A Andraw111

          Hi, Brij. Thank you for your reply. When click button I call a function in .cs file. Can I avlid postback if use this way? I also search internet and try to user javascript to solve it, but failed. To access gridview row information like the following, I put it in block. But this doesn't work, get error "Object Required" in line: rows = document.getElementById(gridName).rows; also ask a silly question, since the javascript block is inside <head runat = "server"> </head>, it will executed in server side or client side? Thanks</x-turndown>

          B Offline
          B Offline
          Brij
          wrote on last edited by
          #7

          Itll be better if you use updatepanel then your posstback wont occur only your grid will be updated. And how to use updatepanel Have a look

          Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

          A 1 Reply Last reply
          0
          • B Brij

            Itll be better if you use updatepanel then your posstback wont occur only your grid will be updated. And how to use updatepanel Have a look

            Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

            A Offline
            A Offline
            Andraw111
            wrote on last edited by
            #8

            Hi, Brij, I got an error "Unknown server tag 'asp:ScriptManager'.", what should I do to use it?

            B 1 Reply Last reply
            0
            • A Andraw111

              Hi, all, I use Asp.net 2.0. I create a ImageButton in a gridview row with category ID, when click it I will call function to show or hide all the rows with the same category ID, everything works fine. But the problem is that every time the button is click, the postback is called, how can I stop that? or have any better way to achieve my purpose, Thanks a lot.

              A Offline
              A Offline
              Andraw111
              wrote on last edited by
              #9

              I also curious why I cannot use javascript to achieve it. I find some codes by using javascript, but when I try it, doesn't work.

              1 Reply Last reply
              0
              • A Andraw111

                Hi, Brij, I got an error "Unknown server tag 'asp:ScriptManager'.", what should I do to use it?

                B Offline
                B Offline
                Brij
                wrote on last edited by
                #10

                If you are visual studio 2005, then you need to install Ajaxextentions, Download from here Then a new template would be added in vs2005, that is ASP.NETAjaxEnabledWebsite create website of that template and it;ll work. In vs2008 or later it is not required.

                Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

                A 1 Reply Last reply
                0
                • B Brij

                  If you are visual studio 2005, then you need to install Ajaxextentions, Download from here Then a new template would be added in vs2005, that is ASP.NETAjaxEnabledWebsite create website of that template and it;ll work. In vs2008 or later it is not required.

                  Cheers!! Brij Check my latest Article :Exploring ASP.NET Validators

                  A Offline
                  A Offline
                  Andraw111
                  wrote on last edited by
                  #11

                  Brij, Yes, I work on VS2005. Since I am new to Asp.net, is there any simple way to achieve my purpose instead of AJAX? Thanks!

                  1 Reply Last reply
                  0
                  • A Andraw111

                    Hi, all, I use Asp.net 2.0. I create a ImageButton in a gridview row with category ID, when click it I will call function to show or hide all the rows with the same category ID, everything works fine. But the problem is that every time the button is click, the postback is called, how can I stop that? or have any better way to achieve my purpose, Thanks a lot.

                    S Offline
                    S Offline
                    SamRST
                    wrote on last edited by
                    #12

                    Hi, As far i know, You want to show the Master/Detail Grid view. ie, if u click the [more] button (imagebutton), u want to show the detailed/ sub grid. if i caught you correct, let me know, so that i can give u a gud solution. http://www.progtalk.com/viewarticle.aspx?articleid=54 http://www.giswiz.com/nested\_gridview\_dropdown/Default.aspx cheers, Sam

                    modified on Thursday, April 22, 2010 3:45 AM

                    A 1 Reply Last reply
                    0
                    • S SamRST

                      Hi, As far i know, You want to show the Master/Detail Grid view. ie, if u click the [more] button (imagebutton), u want to show the detailed/ sub grid. if i caught you correct, let me know, so that i can give u a gud solution. http://www.progtalk.com/viewarticle.aspx?articleid=54 http://www.giswiz.com/nested\_gridview\_dropdown/Default.aspx cheers, Sam

                      modified on Thursday, April 22, 2010 3:45 AM

                      A Offline
                      A Offline
                      Andraw111
                      wrote on last edited by
                      #13

                      Sam, Yes, you are right. I alreay solve my question by using javascript to show/hide group rows in gridview. I have another question, why the grid always has one more empty row as last row of the gridview grid, how can I avoid it? Thanks!

                      A 1 Reply Last reply
                      0
                      • A Andraw111

                        Sam, Yes, you are right. I alreay solve my question by using javascript to show/hide group rows in gridview. I have another question, why the grid always has one more empty row as last row of the gridview grid, how can I avoid it? Thanks!

                        A Offline
                        A Offline
                        Andraw111
                        wrote on last edited by
                        #14

                        Same, just like the example in the link you reply, if I expend two category, and keep other collapse, after I click sort button, I still want to keep these two category expend, how can I do that? Do you have any example to this case? Thanks!

                        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