Click here to Skip to main content
12,457,938 members (50,435 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
Dim strSQL1 As String = "SELECT * FROM ( SELECT [Regno], [FeeType], [SName], [AmountPaid], [Class] FROM FeeTrans) AS DT " & _
     " PIVOT(SUM([AmountPaid]) FOR [FeeType] IN ([Jan],[Feb],[Mar],[Apr])) as PT WHERE Class='" & cboClass.Text & "'"
        Dim DaAp1 As New SqlDataAdapter(strSQL1, con)
        Dim Dset1 As New DataTable
        DaAp1.Fill(Dset1)
        DataGridView1.DataSource = Dset1
 
        With DataGridView2
            .Columns.Add("Regno", "RegNo")
            .Columns.Add("SName", "Name")
            .Columns.Add("Class", "Class")
 
            'HOW CAN I ADD COLUMN (FeeType Data [Jan],[Feb],[Mar],[Apr]))        End With

        For Each dr As DataRow In Dset1.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")
 
                'Here Need FeeType Releted AmountPaid.. Details for PArticular Column Wise            End With
        Next
My I WANT LIKE THIS...My DGV
I want to display it in following format:
RegNo Name Class Jan Feb Mar Apr
100   AAA  I     200 0   200 100
200   AAA  I     500 100 0   0
300   AAA  I     100 200 50  100
Posted 18-Feb-13 20:43pm
Updated 19-Feb-13 4:32am
v3

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 | Mobile
Web02 | 2.8.160826.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2016
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