Click here to Skip to main content
15,898,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all

I have a column for amount in the grid.
user can enter multiple items.

so i have to show them the total amount in a text box.

Please tell me how to do that..

I wrote this but not getting as expected

VB
Dim totalSum As Integer
      Dim ds As New DataSet
      For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
          totalSum += ds.Tables(15).Rows(i).Item("TotalAmt")
      Next

      txtTotalAmount.Text = totalSum.ToString




Thank you
Posted
Updated 6-Nov-13 17:20pm
v2
Comments
ArunRajendra 6-Nov-13 23:29pm    
Be clear with the problem. Tell exactly what's the problem you are facing. Just mentioning "not getting as expected" will not help borders to answer your query.
Snehasish00 6-Nov-13 23:31pm    
Thanks to all..i have solved..

1. Declare a variable to hold the total amount.
2. Loop through the grid and add each row's amount to the total variable.
3. Set the textbox's text property to the variable, formatted as you desire.

If you are not sure how to do these things, try searching for help on google first. Once you have some code, if it is still not working, please click the Improve question link and add your code to your question. Then we can help you fix it.

Hope this helps.
 
Share this answer
 
Comments
Snehasish00 6-Nov-13 23:20pm    
Please check the improved question..
I have used below code

VB
Dim TOTAL As Double = 0
     For Each row As DataRow In dTable.Rows
         TOTAL += Double.Parse(row("TotalAmt").ToString())
     Next
     txtTotalAmount.Text = TOTAL
 
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