Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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.

C#
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;       
    }
Posted
Updated 12-Jul-12 21:16pm
v2
Comments
[no name] 13-Jul-12 10:31am    
You will not get very far without trying. This shows that you have not even tried to do anything at all. Calculating ticket cost is simple basic math and you have shown zero effort.

1 solution

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!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900