Jquery在gridview中计算文本框(gridview在datalist中) [英] Jquery calculate textbox inside gridview (gridview is inside a datalist)
问题描述
我想使用Jquery在gridview中添加所有文本框的值。 Gridview本身就在里面。
a datalist。
Datalist及其gridviews动态绑定。
我想显示每个gridview的文本框总和。
请给我帮助。
提前致谢。
我的尝试:
//// Jquery Code
$(document).ready(function(){
$(。txt_style)。keyup(function(){
var grandTotal = 0;
$([id * = txtValue])。each(function(index){
var value = $ (this).val();
if(value!=&& value!=。){
grandTotal = grandTotal + parseFloat(value );
}
});
$([id * = lblTotal])。html(grandTotal.toString()) ;
});
}); < br $>
/// HTML
< asp:DataList ID =DetBillTyperunat =server OnItemDataBound =DetBillType_ItemDataBoundRepeatColumns =2RepeatDirection =Horizontal>
< itemtemplate>
< asp:GridView ID =grdBillingDetailsrunat =serverAutoGenerateColumns =false
CellPadding =2CellSpacing =2
HorizontalAlign =中心ShowFooter =true交替RowStyle-CssClass =alt
CssClass =网格
宽度=100%OnRowDataBound =grdBillingDetails_RowDataBound>
< columns> < asp:TemplateField HeaderText =Bill Type>
< itemtemplate>
< asp:Label ID =lblBillTyperunat =serverText = '<%#Eval(Description)+*%>'>
< footertemplate>
< b>
< asp:Label ID =lblttotalrunat =serverText =Total Amount/>
< itemstyle cssclass =gridItemStyle>
< HeaderStyle HorizontalAlign =Left/>
< asp:TemplateField HeaderText =>
< itemtemplate>
< asp:TextBox ID =txtValuerunat =serverMaxLength =10Text ='<%#Eval(VALUE)% >'
CssClass =txt_styleonKeyPress =return numbersonly(event,true)autocomplete =off>
< footertemplate>
< asp:Label ID =lblTotalrunat =serverText =>
Hi,
I want to add value of all textboxes inside gridview using Jquery. Gridview is itself inside
a datalist.
Datalist and its gridviews are binded dynamically.
I want to display the sum of textboxes for each gridview.
Please provide me help.
Thanks in advance.
What I have tried:
//// Jquery Code
$(document).ready(function () {
$(".txt_style").keyup(function () {
var grandTotal = 0;
$("[id*=txtValue]").each(function (index) {
var value = $(this).val();
if (value != "" && value != ".") {
grandTotal = grandTotal + parseFloat(value);
}
});
$("[id*=lblTotal]").html(grandTotal.toString());
});
});
/// HTML
<asp:DataList ID="DetBillType" runat="server" OnItemDataBound="DetBillType_ItemDataBound" RepeatColumns="2" RepeatDirection="Horizontal">
<itemtemplate>
<asp:GridView ID="grdBillingDetails" runat="server" AutoGenerateColumns="false"
CellPadding="2" CellSpacing="2"
HorizontalAlign="Center" ShowFooter="true" AlternatingRowStyle-CssClass="alt"
CssClass="Grid"
Width="100%" OnRowDataBound="grdBillingDetails_RowDataBound">
<columns> <asp:TemplateField HeaderText="Bill Type">
<itemtemplate>
<asp:Label ID="lblBillType" runat="server" Text='<%#Eval("Description")+" *"%>'>
<footertemplate>
<asp:Label ID="lblttotal" runat="server" Text="Total Amount" />
<itemstyle cssclass="gridItemStyle">
<HeaderStyle HorizontalAlign="Left" />
<asp:TemplateField HeaderText="">
<itemtemplate>
<asp:TextBox ID="txtValue" runat="server" MaxLength="10" Text='<%#Eval("VALUE")%>'
CssClass="txt_style" onKeyPress="return numbersonly(event, true)" autocomplete="off">
<footertemplate>
<asp:Label ID="lblTotal" runat="server" Text="">
推荐答案
(文件).ready(function(){
(document).ready(function () {
(。txt_style)。keyup(function(){
var grandTotal = 0;
(".txt_style").keyup(function () {
var grandTotal = 0;
([id * = txtValue])。each(function(index){
var value =
("[id*=txtValue]").each(function (index) {
var value =
这篇关于Jquery在gridview中计算文本框(gridview在datalist中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!