![](/img/trans.png)
[英]Client side validation for Textbox inside Gridview control Using Javascript Or Jquery
[英]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. 這是。
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:標簽的 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.