Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Quote:
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
Comments
DinoRondelly at 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 at 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
DaAp7.Fill(DSet7)
'========================================
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
Me.DataGridView1.Rows.Add()
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
Next

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 901
1 OriginalGriff 445
2 CPallini 255
3 Richard Deeming 175
4 George Jonsson 161
0 OriginalGriff 5,540
1 Sergey Alexandrovich Kryukov 4,668
2 CPallini 4,540
3 George Jonsson 3,102
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2014
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