Gridview Footer row textbox in JavaScript

久未见 提交于 2019-12-22 01:32:25

问题


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 + '<^>';
        }
    }

回答1:


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) {
 }



回答2:


It works by simple logic:

var grid = document.getElementById('<%= GridviewName.ClientID %>');
var FooterTextBoxName = grid.getElementsbyTagName('FooterTextBoxName');


来源:https://stackoverflow.com/questions/20466353/gridview-footer-row-textbox-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!