I want to read some records from xml file using LINQ and bind to datagridview control
XDocument xdoc = XDocument.Load("Simple.xml");var
query1 = from books
in xdoc.Elements("NewDataSet").Elements("Table")
select books;
DataTable dttemp =
new DataTable();
dttemp = query1.CopyToDataTable();
dataGridView1.DataSource = dttemp;
but in my situation i dont know how many columns will coming(because based on application situation it'll create different number of column name so that i cant specify column names) if i execute the the same query then it will not bind anything instead of
bind the records i write one for loop
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: bind records to datagridview using LINQ?
Jan 27, 2009 01:37 PM|LINK
If you want yo bind All columns just set Autogeneratecolumns=true
and do
dataGridView1.DataSource = dttemp;
dataGridView1.DataBind(); // this is missing is ur code
Contact me