0

I am having a ASP.net web page. It is some sort of order page ...

we have table on that page. the columns are Name of product, unit price, Quantity, Total price of the product. there are multiple products in rows of table

The Quantity column have TextBox for inputting the value.

I have one Calculate button... on clicking that the Total Price column should display the calculated value of products.

on button click all products rows "Total Price" column should display calculated value (Quantity * UnitPrice)

I am not getting how to achieve that, as im new to ASP.NET.

Any Idea ?

7
  • 1
    what are you using asp.net controls or html controls. for asp.net you can refer using thier name and for html you have to use javascript or jquery for code Commented Mar 14, 2012 at 8:36
  • 1
    displaying the code you have developed so far will be helpful for others to suggest an answer Commented Mar 14, 2012 at 8:42
  • i have used html tags to create the table. <table></table>. but how can i achieve the displaying in table using javascript? Also i haven't write code in CodeBehind. Commented Mar 14, 2012 at 8:59
  • 1
    retag your question, add some other tags like Javascript if you, as you said, want to use javascript. Commented Mar 14, 2012 at 9:09
  • @Vijay if you are not constrained with javascript then you should use jquwery that will ease a lot of your work Commented Mar 14, 2012 at 9:25

3 Answers 3

1

Check this example I have used jQuery jQuery: .each()

Sign up to request clarification or add additional context in comments.

2 Comments

Sorry Sir, I just don't getting how to do it. i want to take unit price from database and count from web page .... and on clicking calculate button i want to show result in table's column, for each row just like that site i have told. i checked your example but nothing is happening...i have attached debug pointer but it is not even going to that point... totally confused.. might be i am doing something wrong. i'm new to asp.net and really got frustrated. please suggest how can i achieve that.
but if i have to use datagrid now then i have to replace all my Table. Also i have to fill the table partially with the fixed texts and partially with the fields from database... and also after calculation i have to modify the values in particular column cell too. How can i achieve that?
0

Here's another one that doesn't reach for jQuery.

http://jsfiddle.net/adrianjmartin/gr5Fr/25/

3 Comments

Sorry Sir, I just don't getting how to do it. i want to take unit price from database and count from web page .... and on clicking calculate button i want to show result in table's column, for each row just like that site i have told. i checked your example but nothing is happening...i have attached debug pointer but it is not even going to that point... totally confused.. might be i am doing something wrong. i'm new to asp.net and really got frustrated. please suggest how can i achieve that
Have a look at the Repeater control[msdn.microsoft.com/en-us/library/zzx23804(v=vs.85).aspx] or the GridView[msdn.microsoft.com/en-us/library/… control to get your data on to the page.
but if i have to use datagrid now then i have to replace all my Table. Also i have to fill the table partially with the fixed texts and partially with the fields from database... and also after calculation i have to modify the values in particular column cell too. How can i achieve that?
0

If you have hard coded your table as your comments suggest then why not just do

int ProductOneTotal = (int)ProductOnePrice.Text * (int)ProductOneAmount.Text;
int ProductTwoTotal = (int)ProductTwoPrice.Text * (int)ProductTwoAmount.Text;

      ...and so on for each product and then.

int ProductTotal = ProductOneTotal + ProductTwoTotal + ....the rest;

Leaving you with ProductTotal which is the total value.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.