计算文本框值 [英] calculating the text box values

查看:107
本文介绍了计算文本框值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在按钮单击事件中,我想计算成人和儿童的总费用,个人费用在数据列表中.帮我解决这个问题.

In button Click event i want to calculate the total cost for the adults and children, the individual cost am having in datalist. help me to solve this.

protected void datalist_p(object source, DataListCommandEventArgs e)
    {
      Label   link1 = (Label)e.Item.FindControl("lbl_adult");
        double  a = Convert.ToDouble( link1.Text);
        calculation(a);
        Label link2 = (Label)e.Item.FindControl("lbl_child");
        double b = Convert.ToDouble(link2.Text);

        calculation2(b);
    }
    public double calculation(double link)
    {
        double link1 = link;
        return link1;       
    }
    public double calculation2(double linka)
    {
        double link2 = linka;
        return link2;       
    }

推荐答案

说实话,那是垃圾.

忽略您的计算例程不会对数据做任何事情,即使您不使用它们也不会使用结果.
您需要检查无效值,以防用户错误输入"12W.6",并且需要制定某种机制来使用可能实际计算得出的任何结果.

否.此刻,您似乎已收到家庭作业,决定我不能打扰",并在此张贴了任何旧的废话,希望我们能为您完成工作.恐怕不是它的工作方式.

我们不做您的作业:这是有原因的.在这里,您可以考虑自己被告知的内容,并尝试理解它.也可以在那里帮助您的导师识别您的弱点,并将更多的注意力放在补救措施上.

自己尝试,您可能会发现它并不像您想的那么难!

如果您遇到实际问题,请先询问一下,但不要再试一次!
To be painfully honest, that is garbage.

Ignoring that your calculation routines don''t do anything with the data, if they did you don''t use the results anyway.
You need to check for invalid values, in case a user types "12W.6" by mistake, and you need work out some mechanism for using any result you might actually calculate ate some point.

No. At the moment, that looks like you have received your homework, decided "I can''t be bothered" and just posted any old rubbihs here in the hope that we will do the work for you. Not the way it works, I''m afraid.

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you have an actual problem, then ask about it, but don''t try this again!


这篇关于计算文本框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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