Click here to Skip to main content
15,851,915 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi can anyone tell me how do i put load linq query into datatable then populate into datagridview?
my codes are as follows:
VB
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:
VB
DataGridView3.AutoGenerateColumns = True
           DataGridView3.DataSource = query

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

additional information copied from comment below
The problem is:
my data are not loading out. the form sort of hang there. it doesnt populate anything.
hope you could help me out with it.
Posted
Updated 1-Aug-13 0:43am
v2
Comments
Jameel VM 1-Aug-13 1:09am    
what's the problem?
12345_abcde 1-Aug-13 1:23am    
my data are not loading out. the form sort of hang there. it doesnt populate anything.
hope you could help me out with it.

1 solution

VB
DataGridView3.AutoGenerateColumns = True
          DataGridView3.DataSource = query.ToList()

DataGridView3.DataBind()
 
Share this answer
 
Comments
12345_abcde 1-Aug-13 5:39am    
i tried. but its not working ):
Vandana_Pathak 1-Aug-13 7:15am    
can i know what problem actually raised?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900