Click here to Skip to main content
13,451,919 members (48,661 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Table1 Name is (Fees_Transaction)

RegNO ST_Name Amount_Paid Class Section
A100 AAAA 750 I A
A200 BBBB 500 I B
A300 CCCC 800 I A
A400 DDDD 450 I A

Table2 Name is (FeesMaster)

RegNO SName TotalAmount Class Section
A100 AAAA 1500 I A
A200 BBBB 1500 I B
A300 CCCC 1500 I A
A400 DDDD 1500 I A

I Want DataGridView Like This

RegNO ST_Name PaidAmountTotalAmountClass Section
A100 AAAA 750 1500 I A
A200 BBBB 500 1500 I B
A300 CCCC 800 1500 I A
A400 DDDD 450 1500 I A

Please HElp me..
Posted 14-Jan-13 8:18am
DinoRondelly 14-Jan-13 18:10pm
How about you create a datatable and add you columns and values to it and then use your new datatable as your datasource for your grid ?
Navas Khanj 15-Jan-13 1:27am
I am Using Code this for DatagridView .. datagrid compain two talbel(Table1, Table2).
Table1 Filed is: Regno, ST_Name, AmountPaid, FeeType, Class, Section
Table2 Filed is: Regno, Sname, FeeAmount, FeeType, Class, Section. Below I used code..please tell me.. wht problem that..

Dim strSQL7 As String = "SELECT Fees_Transaction.Regno,Fees_Transaction.ST_Name,Sum(Fees_Transaction.Amount_Paid)as TotalAmountPaid,FeesMaster.FeeAmount,Fees_Transaction.FeeType,Fees_Transaction.Class,Fees_Transaction.Section FROM Fees_Transaction INNER JOIN FeesMaster ON Fees_Transaction.Regno=FeesMaster.Regno WHERE Fees_Transaction.class='" & cboClass.Text & "' and Fees_Transaction.section='" & cboSection.Text & "' and Fees_Transaction.FeeType='" & cboFeeType.Text & "' GROUP BY Fees_Transaction.Regno,Fees_Transaction.ST_Name,Fees_Transaction.FeeType,Fees_Transaction.Class,Fees_Transaction.Section,FeesMaster.FeeAmount"
Dim DaAp7 As New SqlDataAdapter(strSQL7, con)
Dim DSet7 As New DataTable
With Me.DataGridView1
.Columns.Add("Regno", "RegNo")
.Columns.Add("ST_Name", "Student Name")
.Columns.Add("Amount_Paid", "Amount Paid")
.Columns.Add("Remaining", "Remaining")
.Columns.Add("TotalAmt", "Total Amount")
.Columns.Add("FeeType", "Fee Type")
.Columns.Add("Class", "Class")
.Columns.Add("Section", "Section")
.Columns(0).Width = 85
.Columns(1).Width = 250
.Columns(2).Width = 150
.Columns(3).Width = 150
.Columns(4).Width = 140
.Columns(5).Width = 150
.Columns(6).Width = 90
.Columns(7).Width = 90
' .AllowUserToAddRows = False
.EditMode = DataGridViewEditMode.EditProgrammatically
.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter
End With

For Each dr As DataRow In DSet7.Rows
With Me.DataGridView1.Rows(Me.DataGridView1.Rows.Count - 1)
.Cells("Regno").Value = dr("Regno")
.Cells("ST_Name").Value = dr("ST_Name")
.Cells("Amount_Paid").Value = dr("TotalAmountPaid")
'.Cells("TotalAmt").Value = dr("FeeAmount")
.Cells("FeeType").Value = "Total"
.Cells("Class").Value = dr("Class")
.Cells("Section").Value = dr("Section")
End With

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180318.3 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100