0

hi can anyone tell me how do i put load linq query into datatable then populate into datagridview?
my codes are as follows:

Dim dt As New DataTable

            '' Create 3 typed columns in the DataTable.
            dt.Columns.Add("ConflictingPaper", GetType(String))
            dt.Columns.Add("Numberofstudents", GetType(String))
            dt.Columns.Add("AdminNo", GetType(String))
            'Dim query1 = (From a In dt3 Group Convert.ToString(a.Field(Of Integer)("PaperNo")) By AdminNo = (a.Field(Of String)("AdminNo")) Into Group Select dt.LoadDataRow(New Object() {String.Join(":", Group.ToArray()), Group.Count(), AdminNo}, False)).ToList().Count()



            Dim query = From r In dt3.AsEnumerable() Let adminno = r.Field(Of String)("AdminNo") Group r By adminno Into Group Select New With {.AdminNo = adminno, .numberofstudents = Group.Count(), .conflictingpaper = String.Join(":", Group.Select(Function(r) r.Field(Of Integer)("paperno").ToString()))}



            DataGridView3.AutoGenerateColumns = True
            DataGridView3.DataSource = query

this:

DataGridView3.AutoGenerateColumns = True
           DataGridView3.DataSource = query

doesn't work.
My data are not loading out.
anyone help me out with this? thanks!

3
Contributors
2
Replies
17
Views
4 Years
Discussion Span
Last Post by kRod
0

If all your tables are actually filled with data then

 DataGridView3.DataSource = query.ToList

should load your DataGridView

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.