使用asp.net添加文本框值? [英] adding the textbox values using asp.net ?

查看:101
本文介绍了使用asp.net添加文本框值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI.


我被带到一个网格视图,在该网格视图中有6个文本框(sun1b,mon1b,...... total1b),我想添加(求和)没有"ADD Button"的那些文本框值''点击.

是否可以添加文本框值?请帮帮我!

HI.


I was taken one grid view, in that gridview there is 6 text boxes are there (sun1b,mon1b,...... total1b), I want to add (sum) those textbox valus without ''''ADD Button ''''click .

It is possible to add the textbox values ? pls help me!!

推荐答案

我实际上并没有遇到确切的问题.但是,这是如何在gridview中获取文本框值并将其求和的方法.

I do not actually get the exact problem. But here is how to get the textbox values inside a gridview and sum it.

TextBox txt1;
TextBox txt2;
int sumPerRow = 0;
foreach(GridViewRow row in GridView1.Rows)
{
   txt1 = (TextBox)row.Cells[0].FindControl("sun1b");
   if(String.IsNullOrEmpty(txt1.Text))
   {
      txt1.Text = "0";
   }
   txt2 = (TextBox)row.Cells[1].FindControl("mon1b");
   if(String.IsNullOrEmpty(txt2.Text))
   {
      txt2.Text = "0";
   }

   sumPerRow = Convert.ToInt32(txt1.Text) + Convert.ToInt32(txt2.Text);
}



希望你从这里得到它.逻辑是我的朋友. :)

问候,
爱德华



Hope you get it from here. The logic is there my friend. :)

Regards,
Eduard


这是可能的.从上述解决方案中,您将获得如何添加文本框值.但是请确保输入的值必须是数字,而不是字母数字或任何其他符号,也用于此用途验证.
通过此操作,您可以轻松进行计算,而不会出现任何错误.
This is possible. from above solution you will get how to add the textbox values. But be sure that value enter that must be numeric not alphanumeric or any other symbol, for this use validation also.
From this you will do easy calculation without any error.


这篇关于使用asp.net添加文本框值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆