使用javascript在客户端的gridview中设置标签控件文本属性

时间:2011-05-31 06:04:55

标签: javascript

        function ValidateText(i) {
            if (i.value.length > 0) {
                i.value = i.value.replace(/[^\d]+/g, '');
                var yourBoundColumnValue = i.parentNode.previousSibling.childNodes[0].nodeValue;
                var total = 0;            
                var tot = document.getElementById('<%=lblBalQty.clientId %>').innerHTML
                alert(Number(tot));
                tot.innerHTML = i.value;
                tot.innerHTML = yourBoundColumnValue - i.value;
            }
        }

2 个答案:

答案 0 :(得分:0)

 function calculate(object) {

        var _name = object.id;
        var New = _name.split('_');
        if (object.value.length > 0) {
            object.value = object.value.replace(/[^\d]+/g, '');
        }
        var _ans = 0;
        var _num1 = document.getElementById(New[0] + "_" + New[1]+ "_" + New[2] + "_" + New[3] + "_txtSupQty").value;
        if (_num1 == 'NaN' || _num1=='') {
            _num1 = 0;
        }
        var yourBoundColumnValue = object.parentNode.previousSibling.childNodes[0].nodeValue;
        if (parseInt(_num1) >= 0 && _num1 != 'NaN' ) {
             _ans = parseInt(yourBoundColumnValue)-parseInt(_num1);
         }
         document.getElementById(New[0] + "_" + New[1] + "_" + New[2] + "_" + New[3] + "_lblBalQty").innerHTML = parseFloat(_ans);                
    }                                

答案 1 :(得分:0)

<asp:TemplateField HeaderText="">

<ItemTemplate>
<asp:Button ID="btn_delete_row" runat="server" OnClientClick="qrowdetele(this)" Text="Delete Row" class="btn" />

                                             </ItemTemplate>
                    </asp:TemplateField>

在gridview内部传递objcet这是javascript函数然后 javascript函数。就是这样。

function qrowdetele(rowobject)
        {
            var row = rowobject.parentNode.parentNode;
            var rowIndex = row.rowIndex - 1;

           //getting data
            var lablevalue= document.getElementById("ContentPlaceHolder1_grd_view_lbl_for_update_status_"+rowIndex)[0].value;

            alert("RowIndex: " + rowIndex + "lable value:" +lablevalue);

//setting data 
        document.getElementById("ContentPlaceHolder1_grd_view_lbl_for_update_status_" + rowIndex)[0].value = "MarkedForDeletion";



        }

ContentPlaceHolder1_grd_view_lbl_for_update_status_

ContentPlaceHolder1:girdview所在的内容文件夹的id(这里是主子页面概念中的子页面,因此在正常页面中不需要)

grd_view:是gridview的id

lbl_for_update_status:标签的内容