Gridview Footer row textbox in JavaScript

2019-04-17 01:14发布

I have been accessing the rows of Gridview quite easily using javascript. But when I try to add a new row and then try to access, then the code is not working. Is there a way by which I can access the footer row text box?

Below is my code which works well when edit mode text boxes are to be accessed. Please donot post any link.

function OnSelectIndexChange() {
        var drpdwn = document.getElementById("ddlSelectUnderwriterCond");
        var drpdwnValue = drpdwn.options[drpdwn.selectedIndex].text;
        var gridview = document.getElementById("<%= StandardUndewritingGrid.ClientID %>");
        for (var i = 1; i <= gridview.rows.length; i++) {
            var labels = gridview.rows[i].cells[0].getElementsByTagName("input")[0].value;
            var txtbx = gridview.rows[i].cells[0].children[0];
            if (drpdwnValue != '-- Select --')
                txtbx.value = labels + '<^>' + drpdwnValue + '<^>';
        }
    }

2条回答
贼婆χ
2楼-- · 2019-04-17 01:23

It works by simple logic:

var grid = document.getElementById('<%= GridviewName.ClientID %>');
var FooterTextBoxName = grid.getElementsbyTagName('FooterTextBoxName');
查看更多
爷、活的狠高调
3楼-- · 2019-04-17 01:26

I have just figured out a way of accessing the footer row and code is working fine so I am posting as it might help someone as well:

var flabels = document.getElementById('<%=((TextBox)gridname.FooterRow.FindControl("controlname")).ClientID %>');
 if (flabels != null) {
 }
查看更多
登录 后发表回答