Gridview Problem
-
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
-
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
Use this: lbl.value= out
Parwej Ahamad g.parwez@gmail.com
-
Use this: lbl.value= out
Parwej Ahamad g.parwez@gmail.com
-
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
-
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.
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
-
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
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
-
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
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
-
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
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.
-
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
-
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.
-----
I Would suggest to use AJAX.
-
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
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