Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Total for each Row in Grid

Status
Not open for further replies.

Malam02

MIS
Jul 29, 2024
6
US
How do I loop through Grid1 and get the "Total Credits" for each student in Grid2?
For example: The student ID 99 should have 12 in the "TotalCredits" column in Grid2.

I am using DevXpress Grid control.
Grid_z1prdq.png
 
I assume you get all your data in Grid1 from the database, then do this for Grid2:

[tt]Select StudentID, Sum(Credit) As TotalCredits
From ATable
Group By StudentID[/tt]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
No, that data is not coming from the database.
I have a button to refresh Grid2 and that refresh method needs to get total values from Grid1.
 
IMHO it's impossible to help you, without seeing your minimum working source code.
 
mikrom said:
minimum working source code

At the least, how do you populate Grid1?

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
I am not populating the grid, the values are entered manually in each cell.
If I entered 4 in column "Credit" of row 1 of Grid1, and then click on "Refresh" button that is on the page; the column "Total Credits" of Row 1 in Grid2 should display 4

If I entered 6 in column "Credit" of row 2 of Grid1, and then click on "Refresh" button that is on the page; the column "Total Credits" of Row 1 in Grid2 should display 10 because the row 1 and row 2 of Grid1 has the same "Student ID".
 
So, what stops you from entering:

[pre]
StudentID Course Number Credit Description
99 1 4 Desc99
99 [red] 8 4 [/red] Desc99
99 [red] 8 3 [/red] Desc99
99 [red] 8 2 [/red] Desc99
77 2 4 Desc77
99 [red] 8 1 [/red] Desc99
[/pre]
And would Grid2 have 8, 13 or 14 in Total Credits for StudentID 99?

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
I see not much help from this place, either.

Looks to me like a class assignment. [ponder]

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
If using your sample data, the Grid2 should have 14 in Total Credits for StudentID 99.

If using my sample data, the Grid2 should have 12 in Total Credits for StudentID 99.
 
Every response here creates even more questions.
In my example, StudentID 99 took Course Number 8 four (4) times (is that even possible?) and each of (the same) Course gives different number of Credits (again, is that even possible?)

I know your question is not about the underlying logic of the app, but still... Why bother to code something that does not make sense?

And we still do not know if you have any code. And what type of the Grid you are using (FlexGrid? DataGrid? DataGridView?...)



---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
In my original post; I have already mentioned DevExpress and you may need to read that post again.

If you don't have the answer to my question then it's better to stay quiet instead of making comments that do not make any sense. You don't need to worry about a student taking the same course over and over again and getting different credits, this should not be your problem.
 
You did not mention DevExpress anywhere here on TT. You did that in another post on other forum here.
And sine you refuse to answer any questions, I will stay quiet and out.

Good luck.

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Hi Andrzejek,
it was mentioned very briefly in the first post by OP:
Malam02 (MIS) (OP) 29 Jul 24 05:30 said:
...
I am using DevXpress Grid control.
...

First I looked into DevExpress's documentation, to find out how to solve OP's question.
But since OP didn't post any single line of program code, I stopped working on it.
On the other forum, OP got good advice to post the problem on the forums that support the product.
 
Hi mikrom,

There isn't much code, just the basic and it is posted below.

Code:
Imports System.ComponentModel
Imports System.Text


Partial Public Class Form1
    Public Sub New()
        InitializeComponent()

        ' This line of code is generated by Data Source Configuration Wizard
        ' Fill the ExcelDataSource asynchronously
        ExcelDataSource1.FillAsync()
        ' This line of code is generated by Data Source Configuration Wizard
        ' Fill the ExcelDataSource asynchronously
        ExcelDataSource2.FillAsync()
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    End Sub
End Class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top