This is a migrated thread and some comments may be shown as answers.

GridView Performance

1 Answer 120 Views
GridView
This is a migrated thread and some comments may be shown as answers.
gerbrand
Top achievements
Rank 2
gerbrand asked on 15 Apr 2009, 09:08 PM
Hi,

I've got a gridview with a 3level hierarchy.

When loading the view with :

first level: 300 elements
second level: 10 elements
third level: 5 elements

the load goes fast.

But if I'm trying the following load:

first level: 2100 elements
second level: 10 elements
third level: 5 elements

the load goes slow...

I think I had to wait for 10 - 15 minutes before everything was loaded.

Is this due to bad programming or something else?

my code:

var sortedByLft = from c in network 
                  where (c.Rgt - c.Lft) == 1 
                  orderby c.Name ascending 
                  select c; 
 
var checkNetwork = new List<Network>(); 
//display the unique items in the gridview 
foreach (var item in sortedByLft) 
{     
    Application.DoEvents(); 
    //check if item is already added 
    var check = checkNetwork.Find(p => p.Adserver_id == item.Adserver_id); 
    if (check != nullcontinue
    checkNetwork.Add(item); 
    Application.DoEvents(); 
 
    rgvAdlPositions.MasterGridViewTemplate.Rows.Add(new object[] { item.Adserver_id, item.Name }); 
    var template = rgvAdlPositions.MasterGridViewTemplate.ChildGridViewTemplates[0]; 
    foreach(var position in item.Positions) 
    { 
        Application.DoEvents(); 
        //get the method as string 
        var method = Enums.GetMethod(position.Method); 
        //add to row 
        template.Rows.Add(new object[] 
                              { 
                                  item.Adserver_id, position.PosId, 
                                  ownFunctions.ConcatStrings(new List<string
                                                                          { 
                                                                              position.Name, 
                                                                              position.Width.ToString(), 
                                                                              "x"
                                                                              position.Height.ToString() 
                                                                          }), 
                                  method 
                              }); 
        var templateAd = template.ChildGridViewTemplates[0]; 
        foreach(var adPos in position.adserverPositions) 
        { 
            //add adserved position to row 
            templateAd.Rows.Add(new object[] { item.Adserver_id, position.PosId, adPos.name }); 
        } 
    } 

Is it possible that the lines 12 and 28 are the bad ones?
the first one is checking if I have unique elements and the second one is calling a static function to concatenate a list of strings.

Thanks a lot in advanced


1 Answer, 1 is accepted

Sort by
0
Accepted
Julian Benkov
Telerik team
answered on 17 Apr 2009, 04:00 PM
Hello Gerbrand,

You can try using BeginUpdate/EndUpdate methods of GridElement:

radGridView.GridElement.BeginUpdate(); 
 
rgvAdlPositions.MasterGridViewTemplate.Rows.Add(new object[] { item.Adserver_id, item.Name });  
var template = rgvAdlPositions.MasterGridViewTemplate.ChildGridViewTemplates[0];  
foreach(var position in item.Positions)  
{  
    Application.DoEvents();  
    //get the method as string  
    var method = Enums.GetMethod(position.Method);  
    //add to row  
    template.Rows.Add(new object[]  
                          {  
                              item.Adserver_id, position.PosId,  
                              ownFunctions.ConcatStrings(new List<string>  
                                                                      {  
                                                                          position.Name,  
                                                                          position.Width.ToString(),  
                                                                          "x",  
                                                                          position.Height.ToString()  
                                                                      }),  
                              method  
                          });  
    var templateAd = template.ChildGridViewTemplates[0];  
    foreach(var adPos in position.adserverPositions)  
    {  
        //add adserved position to row  
        templateAd.Rows.Add(new object[] { item.Adserver_id, position.PosId, adPos.name });  
    }  
}  
 
radGridView.GridElement.EndUpdate(); 

I hope this helps. If you have additional questions, feel free to contact me.

Greetings,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
gerbrand
Top achievements
Rank 2
Answers by
Julian Benkov
Telerik team
Share this question
or