Developer forum

Forum » Development » GetLoop

Reply
Good Day,

I'm trying to keep a loop and reuse it.

This is the code:

#region Facilities
loopTemplate = template.GetLoop("Facilities");
droptemp = databaseobj.GetDroplistFacilities();

for (int i = 0; i < droptemp.idvalue.Count; i++)
{
    loopTemplate.SetTag("Facility.Code", droptemp.idvalue[i].ToString());
    loopTemplate.SetTag("Facility.Text", droptemp.textvalue[i].ToString());
    loopTemplate.CommitLoop();
}
#endregion

Getloop allow me create a loop in that template, but I need run that code just only one time and avoid to call the data base again.

Keep "loopTemplate" and then use it in other templates is a good idea.

How can I reuse loops in other templates?


Thank you!

Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply
Hi

If you're not getting a huge amount of data, then you can simply cache it. That way you only call the DB once.
Of course you still need to call the code from where ever you need the loop.

- Jeppe

 
Reply
The idea is avoid call the code again.

I'm asking too much, right? lol

Don't worry thank for your help.

 

You must be logged in to post in the forum