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

Gridview Problem

Scheduled Pinned Locked Moved ASP.NET
javascriptdatabasetoolshelptutorial
11 Posts 6 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.
  • E Elizma

    Hi Guys and Gals, I am using a javascript function to update a label in a template column of a gridview. This all works fine, but the problem we are having is that when we want to update the database with the changes, the labels returns the old values instead of the updated values in the labels. Here is our JavaScript. If anyone can tell us what we are doing wrong or how to correct this problem, it will be greatly appreciated. string script = @" function calcQty(QtyPerCarton,Cartons, num) { if(num < 10) num = '0' + num; var i = document.getElementById('dg3_ctl'+num+'_txtCartonsPicked'); var carPicked = i.value; var out; if(carPicked <= Cartons) { out = parseInt(carPicked * QtyPerCarton) } else { alert('Cartons Picked cant be greater than Cartons'); return; } var lbl = document.getElementById('dg3_ctl'+num+'_lblQtyPicked'); lbl.innerHTML = out; } "; this.RegisterStartupScript("Calc", script); Kind Regards, Elizma

    P Offline
    P Offline
    Parwej Ahamad
    wrote on last edited by
    #2

    Use this: lbl.value= out

    Parwej Ahamad g.parwez@gmail.com

    E 1 Reply Last reply
    0
    • P Parwej Ahamad

      Use this: lbl.value= out

      Parwej Ahamad g.parwez@gmail.com

      E Offline
      E Offline
      Elizma
      wrote on last edited by
      #3

      It doesnt work! Visual Studio generates tags in the html output, thus it will not contain the value attribute but only the innerHTML attribute which does not change or update the old value with the new value. Any ohter suggestions? Kind Regards, Elizma

      P 1 Reply Last reply
      0
      • E Elizma

        Hi Guys and Gals, I am using a javascript function to update a label in a template column of a gridview. This all works fine, but the problem we are having is that when we want to update the database with the changes, the labels returns the old values instead of the updated values in the labels. Here is our JavaScript. If anyone can tell us what we are doing wrong or how to correct this problem, it will be greatly appreciated. string script = @" function calcQty(QtyPerCarton,Cartons, num) { if(num < 10) num = '0' + num; var i = document.getElementById('dg3_ctl'+num+'_txtCartonsPicked'); var carPicked = i.value; var out; if(carPicked <= Cartons) { out = parseInt(carPicked * QtyPerCarton) } else { alert('Cartons Picked cant be greater than Cartons'); return; } var lbl = document.getElementById('dg3_ctl'+num+'_lblQtyPicked'); lbl.innerHTML = out; } "; this.RegisterStartupScript("Calc", script); Kind Regards, Elizma

        M Offline
        M Offline
        M LN Rao
        wrote on last edited by
        #4

        What do you want exactly? Do you those values prepared by JS to the updated in DB?

        Intelligence is measured by common sense not by how many scholarly books you read.

        E 1 Reply Last reply
        0
        • M M LN Rao

          What do you want exactly? Do you those values prepared by JS to the updated in DB?

          Intelligence is measured by common sense not by how many scholarly books you read.

          E Offline
          E Offline
          Elizma
          wrote on last edited by
          #5

          I have a gridview. In my gridview I have static data, a textbox column for entering the amount of cartons picked, a label to display the value of the amount of cartons picked / the qty per carton. The javascript takes care of this and display the values in the grid. So, now I have a save button in order to update this data back into the database with the new QtyPicked. Unfortunately the html (if you go to view source) didn't update the old values with the new values. I need the new values to be sent to the database. Any idea what else I can try? Regards, Elizma

          M L 2 Replies Last reply
          0
          • E Elizma

            It doesnt work! Visual Studio generates tags in the html output, thus it will not contain the value attribute but only the innerHTML attribute which does not change or update the old value with the new value. Any ohter suggestions? Kind Regards, Elizma

            P Offline
            P Offline
            Parwej Ahamad
            wrote on last edited by
            #6

            if lbl is not a server side control then how you can access it server side in code behind for save to the Database? Note: you can once more test with lbl.innerText=out;

            Parwej Ahamad g.parwez@gmail.com

            E 1 Reply Last reply
            0
            • P Parwej Ahamad

              if lbl is not a server side control then how you can access it server side in code behind for save to the Database? Note: you can once more test with lbl.innerText=out;

              Parwej Ahamad g.parwez@gmail.com

              E Offline
              E Offline
              Elizma
              wrote on last edited by
              #7

              My Label is a Server side control since it's a Template field of the GridView. The code I am doing is in Javascript that updates the values client-side. Unfortunately the client-side values does not get sent back to the server for saving. Tried innerText as well. Still not working. Regards, Elizma

              1 Reply Last reply
              0
              • E Elizma

                I have a gridview. In my gridview I have static data, a textbox column for entering the amount of cartons picked, a label to display the value of the amount of cartons picked / the qty per carton. The javascript takes care of this and display the values in the grid. So, now I have a save button in order to update this data back into the database with the new QtyPicked. Unfortunately the html (if you go to view source) didn't update the old values with the new values. I need the new values to be sent to the database. Any idea what else I can try? Regards, Elizma

                M Offline
                M Offline
                M LN Rao
                wrote on last edited by
                #8

                I hope you are trying to update values in Gridview's edit mode. If so use #Bind("colname") for the textbox. Hopefully this may solve. But as far as I now if you are placing values from js they do not persists. Lets first try with bind. If does not we need to look for some work around for it.

                Intelligence is measured by common sense not by how many scholarly books you read.

                1 Reply Last reply
                0
                • E Elizma

                  Hi Guys and Gals, I am using a javascript function to update a label in a template column of a gridview. This all works fine, but the problem we are having is that when we want to update the database with the changes, the labels returns the old values instead of the updated values in the labels. Here is our JavaScript. If anyone can tell us what we are doing wrong or how to correct this problem, it will be greatly appreciated. string script = @" function calcQty(QtyPerCarton,Cartons, num) { if(num < 10) num = '0' + num; var i = document.getElementById('dg3_ctl'+num+'_txtCartonsPicked'); var carPicked = i.value; var out; if(carPicked <= Cartons) { out = parseInt(carPicked * QtyPerCarton) } else { alert('Cartons Picked cant be greater than Cartons'); return; } var lbl = document.getElementById('dg3_ctl'+num+'_lblQtyPicked'); lbl.innerHTML = out; } "; this.RegisterStartupScript("Calc", script); Kind Regards, Elizma

                  S Offline
                  S Offline
                  SABhatti
                  wrote on last edited by
                  #9

                  AFAIK, updating the labels on client side does not go back to server. You can keep a hidden field for the same thing and update both the label and the hidden field. On the server get the updated value from the hidden field and save it to the DB.

                  -----

                  S 1 Reply Last reply
                  0
                  • S SABhatti

                    AFAIK, updating the labels on client side does not go back to server. You can keep a hidden field for the same thing and update both the label and the hidden field. On the server get the updated value from the hidden field and save it to the DB.

                    -----

                    S Offline
                    S Offline
                    Saksida Bojan
                    wrote on last edited by
                    #10

                    I Would suggest to use AJAX.

                    1 Reply Last reply
                    0
                    • E Elizma

                      I have a gridview. In my gridview I have static data, a textbox column for entering the amount of cartons picked, a label to display the value of the amount of cartons picked / the qty per carton. The javascript takes care of this and display the values in the grid. So, now I have a save button in order to update this data back into the database with the new QtyPicked. Unfortunately the html (if you go to view source) didn't update the old values with the new values. I need the new values to be sent to the database. Any idea what else I can try? Regards, Elizma

                      L Offline
                      L Offline
                      Lijo Rajan
                      wrote on last edited by
                      #11

                      Hi, Instead of giving update button in the each row of grid u can give a button for updation.In the click event of that button u have to check for the value which is changed in text box.Then u can use button.attribute.add("onclick","JS function") to bind with server these values.Hope this will help u Regrds Lijo

                      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