Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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.
Posted 29-Jan-13 3:18am
Edited 29-Jan-13 3:29am
CHill6061.2K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I didn't go very deep into how you're doing things now, but it appears as though you're trying to display data from 2 different, though related, tables. You're using two different SELECT queries, but not joinging them together.
 
I HIGHLY suggest you read up on and practice some SQL JOIN queries. The DGV cannot display data side-by-side from seperate queries. They MUST be JOIN'd to generate a single datatable or dataview containing all the data you wish to display.
  Permalink  
Comments
Navas Khanj at 30-Jan-13 0:54am
   
Thanks. But I need DGV header text related data want show dgv
Dave Kreskowiak at 30-Jan-13 6:48am
   
I told you what you have to do.
Navas Khanj at 30-Jan-13 7:23am
   
I want DGV LIKE THIS
 
Pleae Check my TABLE 1 ,Table2 and Table 3
 
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
Navas Khanj at 30-Jan-13 7:26am
   
How Can i Get My Table3 Data in DGV (DGV Header Related Data want Display ) LIKE
Team-1 Team-2 BUSFEE
750 0 0
like this

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 540
1 OriginalGriff 300
2 CPallini 290
3 ChauhanAjay 124
4 George Jonsson 120
0 OriginalGriff 6,474
1 Sergey Alexandrovich Kryukov 6,190
2 CPallini 5,180
3 George Jonsson 3,574
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 29 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