Working with datagrid at client-side

fadi

Junior Contributor
Joined
Jul 4, 2003
Messages
209
Location
Lebanon
i have one question, can i work with a datagrid from the client side, i.e, add or delete rows without posting back to the server everytime i need to add or delete a row
thanks alot
 
yes you can do this by javascript.

look at your browsers sourcecode -> the datagrid is rendered as a table. look for the id...

js:
Code:
var tr = document.createElement("tr");
window.document.all["yourTableID"].rows.add(tr);

note: you have to add cells but with the little code above you should get this work...

BUT: After reload your page the added rows are lost!!!

Regards!
 
u mean after a postback is that right
anyways when i postback i will save the new items in a datatable so no pro i guess,
ill c what can i do with the code u gave me,
thanks alot anyways
 
when you do a postback your new added rows will be lost at pageload! this means, you have no access to the js-added rows, so this solution will not work for your problem...

You have no "back-databind" in your grid!!!


workaround:

write in a hidden textbox or hidden field the values you added to you rows (spaced with e.g. "$") , read this server-field at server and write these values to your db...
 
yes i noticed that i can't have access to the newly added rows. ill implement something like the way u suggested,
thanks again
 
Back
Top