Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

C#
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); //Remove Title
        }
    }
    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
C#
function deleteSegmentRow(src) {
    var tb = document.getElementById('<%=this.tbSubM16.ClientID %>'); //Changed Only This Line
    var oRow = src.parentElement.parentElement;
    if (oRow.id != null) {
        if (oRow.tagName=='TR')//Only For Checking if its Row Only{
            tb.deleteRow(oRow.rowIndex);
            var rowCount = tb.rows.length;
            if (rowCount == 1) {
                tb.deleteRow(0); //Remove Title
            }
        }
        //setTotalGrossAmount();
    }
    return false;
}
Posted
Updated 5-Feb-11 19:56pm
v3

1 solution

Answered only to remove from Unanswered list: solved by the OP.
 
Share this answer
 
Comments
Abdul Rahman Hamidy 6-Feb-11 2:03am    
thanks :-)
OriginalGriff 6-Feb-11 2:19am    
You are more than welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900