I've been trying to do this for the past hour and still got nothing. I'll try to explain it so please stay with me:
I'm trying to create a sort of summary shopping cart by creating an HTML table using javascript and adding rows every time an item is selected from the gridview.
I have a gridview with a TemplateField containing a button. The gridview looks like this:
Property | Quantity | Order | Action
Pencil | 10 | (textbox) | (button)
Pen | 5 | (textbox) | (button)
Supposedly, the button has an onclientclick event which will insert a new row to the HTML table (summary shopping cart).
<SCRIPT language="javascript">
function addRow(tableID,property,order) {
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
cell1.innerHTML = property;
var cell2 = row.insertCell(1);
cell2.innerHTML = order;
}
I don't know how to bind this javascript to the (button) in my GridView though. I can't bind it on the DataBound event because I'll have to pass the value of (textbox).