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. Edit Datagrid row On Double Click

Edit Datagrid row On Double Click

Scheduled Pinned Locked Moved ASP.NET
csharpquestion
6 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.
  • A Offline
    A Offline
    asingh70
    wrote on last edited by
    #1

    Hi Guys, I like to edit datagrid row on double click event in c#. Any suggestions ? Thanks in Advance.

    D 1 Reply Last reply
    0
    • A asingh70

      Hi Guys, I like to edit datagrid row on double click event in c#. Any suggestions ? Thanks in Advance.

      D Offline
      D Offline
      DFU23
      wrote on last edited by
      #2

      you could use the client side event ondblclick and fake that to call the javascript __doPostBack function and then handle that on the server side ... might be a bit hary though :)

      Wally Atkins
      Newport News, VA, USA

      A 1 Reply Last reply
      0
      • D DFU23

        you could use the client side event ondblclick and fake that to call the javascript __doPostBack function and then handle that on the server side ... might be a bit hary though :)

        Wally Atkins
        Newport News, VA, USA

        A Offline
        A Offline
        asingh70
        wrote on last edited by
        #3

        Do you have any example. I really appriciate. Thanks

        D 1 Reply Last reply
        0
        • A asingh70

          Do you have any example. I really appriciate. Thanks

          D Offline
          D Offline
          DFU23
          wrote on last edited by
          #4

          Well, it really depends on what functionality you are trying to provide here ... but here is my general thought: When the datagrid is databound try calling a function similar to this ...

          private void AddDoubleClickHandler(DataGrid dg, string ctl) {
          int count = dg.Items.Count;
          for (int i = 0; i < count; i++) {
          dg.Items[i].Attributes.Add("ondblclick", "__doPostBack('" + dg.Items[i].UniqueID.Replace(":","$") + "$_ctl" + ctl + "','');");
          }
          }

          which takes in a datagrid and will add to each row a client side ondblclick event ... which in turn will try to use the __doPostBack function to mimic a control being used. From there you could do a bunch of stuff ... if this seems a bit confusing or a stretch on what you are trying to do I can understand. But, hopefully it will get you heading in the direction you want to go ...

          Wally Atkins
          Newport News, VA, USA

          A 1 Reply Last reply
          0
          • D DFU23

            Well, it really depends on what functionality you are trying to provide here ... but here is my general thought: When the datagrid is databound try calling a function similar to this ...

            private void AddDoubleClickHandler(DataGrid dg, string ctl) {
            int count = dg.Items.Count;
            for (int i = 0; i < count; i++) {
            dg.Items[i].Attributes.Add("ondblclick", "__doPostBack('" + dg.Items[i].UniqueID.Replace(":","$") + "$_ctl" + ctl + "','');");
            }
            }

            which takes in a datagrid and will add to each row a client side ondblclick event ... which in turn will try to use the __doPostBack function to mimic a control being used. From there you could do a bunch of stuff ... if this seems a bit confusing or a stretch on what you are trying to do I can understand. But, hopefully it will get you heading in the direction you want to go ...

            Wally Atkins
            Newport News, VA, USA

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

            Thanks for Suggestion. Actually i try to edit my datagrid any rows any columns when ever i double click this column. same like when we use edit command button on each row. Thanks

            D 1 Reply Last reply
            0
            • A asingh70

              Thanks for Suggestion. Actually i try to edit my datagrid any rows any columns when ever i double click this column. same like when we use edit command button on each row. Thanks

              D Offline
              D Offline
              DFU23
              wrote on last edited by
              #6

              That's what my code example attempts to do ... but my question is how will the user then save the changes? Are the buttons still there for functionality or are you trying to get around using the buttons completely?

              Wally Atkins
              Newport News, VA, USA

              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