Dear All, I have ASP:Table in my aspx page which I am trying delete rows (remove rows) in client side using ajax, I have button in a cell inside the table in each row I call bellow code in onclick event of the button but it doesent work, well bellow code works with HTML table only.
function deleteSegmentRow(src) {
var tb = '<%=this.tbSubM16.ClientID %>';
var oRow = src.parentElement.parentElement;
if (oRow.id != null) {
tb.deleteRow(oRow.rowIndex);
var rowCount = tb.rows.length;
if (rowCount == 1) {
tb.deleteRow(0);
}
}
return false;
}
code for assigning onclick event in backend
btn.Attributes.Add("onclick", "return deleteSegmentRow(this);");
the statement bellow doesent work as it reachs the statement
tb.deleteRow(oRow.rowIndex);
I do solved the issue with bellow Code
function deleteSegmentRow(src) {
var tb = document.getElementById('<%=this.tbSubM16.ClientID %>');
var oRow = src.parentElement.parentElement;
if (oRow.id != null) {
if (oRow.tagName=='TR')
tb.deleteRow(oRow.rowIndex);
var rowCount = tb.rows.length;
if (rowCount == 1) {
tb.deleteRow(0);
}
}
}
return false;
}