| |
You are here: Experts > Computing/Technology > Basic > VB.NET > Working with Datagridview
Expert: Syed Rizwan Muhammad Rizvi
Date: 8/11/2008
Subject: Working with Datagridview
Question QUESTION: Dear Sir, I am the learner of .net. I have a Datagridview which consist of columns ie, Quantity, Unit_Price & Total_amount. When I enter the
the values in Quantity & Unit_Price the Total_Amount Colums calculates the total amount ie, Quantity*Unit_Price,
but how to calculate the sum of Total_Amount column.
Pls can u help me in this matter.
With Regards
Satish M.B
ANSWER: in SQL, you write: Select Sum(Total_Amount) from tblOrderDetails Where OrderID = @OrderID
---------- FOLLOW-UP ----------
QUESTION: Dear Sir, thanks for ur suggestion. But what the thing i need is, I have a Datagridview & a blank dataset with 3 cloumns of Quantity,Unit Price & Total Amount. In expression property of Total Amount I have mentioned as Quantity*Unit_Price, I have bind that blank dataset to Datagridview. I enters the values manually in Quantity & Unit_Price cell & when I moves to next row Total_amount cell will calculate by itself with the help of expression property. I have a text box which will shows the sum of Total_amount column. As & when the cursor moves to next row the sum has to be calculate by itself & shown in text_box. Pls can u help me in this matter.
With Regards
Satish M.B
ANSWER: Post this into asp.net/javascript section as you would require some javascript bound to your textboxes to trap the onfocus/onblur events to do the perform the calculations.
Regards,
Rizwan
---------- FOLLOW-UP ----------
QUESTION: Dear Sir, Pls Sir can U explain me how to calculate the sum of Total_amount column of DataGridView.
With Regards.
Satish M.B
Answer dim tmpTotalAmount as double = 0
For each tmpRow as GridViewRow in GridView1.Rows
tmpTotalAmount += tmprow.cells(5).text 'Cell number 5 refers to the column that contains the TotalSum of each row.
Next
'Here you will have the sum of whole order.
msgbox tmpTotalAmount
Add to this Answer
Ask a Question
|
|