Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey Guys,

Assigning the Linq query result to the DataGrid datasource it takes a lot of time (40 seconds) and I only have 8000 entries (rows)in the XML file. I know that this can be fixed by looping through the Linq result elements and adding them to the grid view one by one but is there any other easy way that comes to your mind?

Thanks in advance

C#
var Log =
    from c in xmlDoc.Descendants("Event")
    select new
    {
        Type = ((string)c.Element("Type").Value),
        Class = ((string)c.Element("Class").Value),
        Method = ((string)c.Element("Method").Value),
        DateTime = ((string)c.Element("DateTime").Value),
        Text = ((string)c.Element("Text").Value),
        StackTrace = ((string)c.Element("StackTrace").Value),
        SourceTable = ((string)c.Element("SourceTable").Value),
        SourceField = ((string)c.Element("SourceField").Value),
        SourceValue = ((string)c.Element("SourceValue").Value),
        TargetTable = ((string)c.Element("TargetTable").Value)
    };

dbGridLog.AutoGenerateColumns = true;
dbGridLog.DataSource = Log.ToList();
Posted
Updated 6-Oct-11 9:15am
v3

1 solution

Setting t he AutoSizeColumnsMode = False; & AutoSizeRowsMode = False; solved it. Now it loads 10000 records in 2 seconds!
 
Share this answer
 

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


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