Click here to Skip to main content
13,256,012 members (48,269 online)

3 Table Show To DataGridView

Navas Khanj asked:

Open original thread
I am Using 3 Table (FeeMaster, StdAdmission, Fees_Transaction) I Want Show DGV LIKE THIS


Here DGV HEADER (Regno , Name, Class, Section)This All come to StdAdmission..
and DGV (Team-1, Team-2,BUSFEE) come to FeeMaster Table Data


Regno Name Class Section Team-1 Team-2 BUSFEE
A101 AAAA I A 750 0 0
A102 BBBB I A 750 300 125
A103 CCCC I A 500 350 0

Table 1
FeeMaster
Class FeeType Fee Amount
I          Team-1     750
II         Team-1     2000
II         Team-2     1500
I          Team-2     650
I          BUSFEE     200
II         BUSFEE     200

Table 2
StdAdmission
Regno Class Section Name
A101 I A AAAA
A102 I A BBBB
A103 I A CCCC
A104 II B DDDD
A105 III A EEEE

Table 3
Fees_Transaction
Regno Name Class Section Amount FeeType
A101 AAAA I A 500 Team-1
A102 BBBB I A 750 Team-1
A103 CCCC I A 500 Team-1
A101 AAAA I A 250 Team-1
A102 BBBB I A 300 Team-2
A103 CCCC I A 350 Team-2
A104 DDDD II A 100 Team-1
A102 BBBB I A 125 BUSFEE

Here I USE CODE
DataGridView2.Rows.Clear()
DataGridView2.Columns.Clear()
Dim strSQL10 As String = "SELECT Regno,Sname,Class,Section FROM stdAdmission WHERE class='" & cboClass.Text & "'"
Dim DaAp10 As New SqlDataAdapter(strSQL10, con)
Dim DSet10 As New DataTable
DaAp10.Fill(DSet10)
 
Dim strSQL7 As String = "SELECT * FROM FeeMaster WHERE Class='" & cboClass.Text & "'"
Dim DaAp7 As New SqlDataAdapter(strSQL7, con)
Dim Dset7 As New DataTable
DaAp7.Fill(Dset7)
 
'========================================
With Me.DataGridView2
    .Columns.Add("Regno", "RegNo")
    .Columns.Add("Sname", "Student Name")
    .Columns.Add("Class", "Class")
    .Columns.Add("Section", "Section")
    For i As Integer = 0 To Dset7.Rows.Count - 1
        .Columns.Add(i, Dset7.Rows(i).Item("FeesType"))
    Next
    .Columns.Add("", "Other")
    .Columns.Add("", "Total")
    .Columns.Add("Mobile1", "Mobile No")
 
    .Columns(0).Width = 85
    .Columns(1).Width = 250
    .Columns(2).Width = 85
    .Columns(3).Width = 85
    .Columns(4).Width = 100
    .AllowUserToAddRows = False
    .EditMode = DataGridViewEditMode.EditProgrammatically
    .ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.TopCenter
End With
 
For Each dr As DataRow In DSet10.Rows
    Me.DataGridView2.Rows.Add()
    With Me.DataGridView2.Rows(Me.DataGridView2.Rows.Count - 1)
        .Cells("Regno").Value = dr("Regno")
        .Cells("Sname").Value = dr("Sname")
        .Cells("Class").Value = dr("Class")
        .Cells("Section").Value = dr("Section")
        .Cells("Mobile1").Value = dr("Mobile1")
 
    End With
Next


This Code DGV Display Like this
Regno Name Class Section Team-1 Team-2 BUSFEE
A101 AAAA I A
A102 BBBB I A
A103 CCCC I A
I want DGV Team-1, Team-2, BUSFEE want Data FROM Fees_Transaction For Class='I'

Regno Name Class Section Team-1 Team-2 BUSFEE
A101 AAAA I A 750 0 0
A102 BBBB I A 750 300 125
A103 CCCC I A 500 350 0

Please Tell me How Can i Get Data For Particular Filed.
Tags: VB, VB.NET

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy |
Web03 | 2.8.171114.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2017
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