Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Dim strSQL17 As String = "SELECT FeesType FROM FeeMaster WHERE Class='" & cboClass.Text & "'" ' ORDER BY FeesType Asc"
        Dim DaAp17 As New SqlDataAdapter(strSQL17, con)
        Dim Dset17 As New DataTable
        DaAp17.Fill(Dset17)
        With Me.DataGridView2
            .Columns.Add("Regno", "RegNo")
            .Columns.Add("Sname", "Name")
            For i As Integer = 0 To Dset17.Rows.Count - 1
                .Columns.Add("Col1", Dset17.Rows(i).Item("FeesType"))
            Next
           
        End With
 

        Dim strSQL27 As String = "SELECT STUFF((SELECT DISTINCT ',['+ FeesType +']' FROM FeeMaster WHERE Class='" & cboClass.Text & "' For XMl Path('')), 1, 1, '')"
        Dim DaAp27 As New SqlDataAdapter(strSQL27, con)
        Dim Dset27 As New DataTable
        DaAp27.Fill(Dset27)
        Dim strSQL11 As String
 
        strSQL11 = "SELECT * FROM (SELECT Regno, FeeType, [Amount_Paid],[ST_Name]  FROM Fees_Transaction) stdAdmission PIVOT (Sum(Amount_Paid) for FeeType in (" + Dset27.Rows(0).Item("Column1") + "))as PVTFT where Class='" & cboClass.Text & "'"
 

        Dim DaAp11 As New SqlDataAdapter(strSQL11, con)
        Dim DSet11 As New DataTable
        DaAp11.Fill(DSet11)
        DGV1.DataSource = DSet11
 

        For Each dr As DataRow In DSet11.Rows
            Me.DataGridView2.Rows.Add()
            With Me.DataGridView2.Rows(Me.DataGridView2.Rows.Count - 1)
 

                .Cells("Regno").Value = dr("Regno")
                .Cells("Sname").Value = dr("ST_Name")
 

‘ HERE I HAVE PROBLEM Cannot Show Amount_Paid on Particular Column. How Can I Get
 
                 For i As Integer = 0 To DataGridView2.ColumnCount - 1
                    .Cells("Col1").Value = dr("Amount_Paid")
                Next
            End With
        Next
 
 
How Can i Get Like This DGV
 
Regno Name Team-1 Team-2 Total
A100 AAA 500 200 700
A200 BBB 200 0 200
A300 CCC 500 100 600
 
Please Tell me.. how can i do for This
Posted 15-Feb-13 4:39am
Edited 15-Feb-13 4:44am
v2

1 solution

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

Solution 1

you have multiple columns on DataGridView2 with name "Col1", have to change
 <pre lang="vb"> 
For i As Integer = 0 To Dset17.Rows.Count - 1
     .Columns.Add("Col1", Dset17.Rows(i).Item("FeesType"))
Next
 
or set cell value for index and not use the name
  Permalink  

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

  Print Answers RSS
0 Maciej Los 225
1 Manfred R. Bihy 190
2 CHill60 180
3 _Amy 155
4 OriginalGriff 150
0 OriginalGriff 7,320
1 Sergey Alexandrovich Kryukov 6,043
2 Maciej Los 3,754
3 Peter Leow 3,448
4 CHill60 2,572


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 15 Feb 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