[英]Setting label control text property in gridview on client side using 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;
}
}
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="btn_delete_row" runat="server" OnClientClick="qrowdetele(this)" Text="Delete Row" class="btn" />
</ItemTemplate>
</asp:TemplateField>
inside gridview pass the objcet this is javascript function and then javascript function. inside gridview pass the objcet this is javascript function and then javascript function. is this.
这是。
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_grd_view_lbl_for_update_status_
ContentPlaceHolder1: id of content palce holder in which girdview is (here is is a child page in master child page concept so no need in normal page) ContentPlaceHolder1:girdview 所在的内容持有者的id(这里是主子页面概念中的子页面,因此在普通页面中不需要)
grd_view: is the id of gridview grd_view:是gridview的id
lbl_for_update_status: id of lable lbl_for_update_status:标签的 id
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.