Gridview页脚值不能与javascript一起使用 [英] Gridview footer value not working with javascript
本文介绍了Gridview页脚值不能与javascript一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是一个gridview,一个名为lbl_pre的前一个值标签列,一个名为txt_pre的文本框列,用于进行输入,另一个名为lbl_sum的标签列将用于以前的值+用户输入值
现在我的lbl_pre + txt_pre值工作正常并且lbl_sum显示正确的输出,但是lbl_sum的总数不起作用。
我尝试了什么:
i m havng a gridview, a previous value lable column called lbl_pre, text box column named txt_pre which is used to make entry , another label named lbl_sum column which will be used for previous value + user enter value
now my lbl_pre + txt_pre value working fine and lbl_sum shown correct output, but total of lbl_sum is not working.
What I have tried:
<script type="text/javascript">
function Calctotal_pre(PreviousValue, txtvalue, TotalValue)
{
var uservalue = parseFloat(document.getElementById(txtvalue).value);
var TotalVar = document.getElementById(TotalValue);
var TotalValue = parseFloat(PreviousValue + uservalue );
TotalVar.innerHTML = TotalValue;
var total_allPY = 0;
$($("[id*=GvList] [id*=lbl_sum]")).each(function ()
{
if (!isNaN(parseFloat($(this).val())))
{
total_allPY += parseFloat($(this).val());
}
});
$("[id*=GvList] [id*=lbl_PY_total]").html(total_allPY);
}
</script>
----------------CODE PART--------------
protected void GvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblList = (Label)e.Row.FindControl("lbl_pre");
PreVal += Convert.ToDecimal(lblList.Text);
txt_pre.Attributes.Add("onkeyup", "Calctotal_pre(" + PreVal + ", '" + txtqut.ClientID + "','" + lbl_sum.ClientID + "')");
}
}
推荐答案
(
([id * = GvList] [id * = lbl_sum]))。each(function()
{
if(!isNaN(parseFloat(
("[id*=GvList] [id*=lbl_sum]")).each(function () { if (!isNaN(parseFloat(
(this))。 val())))
{
total_allPY + = parseFloat(
(this).val()))) { total_allPY += parseFloat(
这篇关于Gridview页脚值不能与javascript一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文