Hello,
I have 10 labels in different parts of a page, each one displaying a
value.
I have a class that uses Linq to retrieve all those values from a
database and places them in its properties.
I don't want to create an instance of this class on each control init
event because I will be accessing the database 10 times.
What is the more correct way to call the data function once and fill
all labels?
Should I use a custom data source. How can I do that?
Thanks,
Miguel
Mark Rae [MVP] - 07 Mar 2008 18:46 GMT
> I have 10 labels in different parts of a page, each one displaying a
> value.
[quoted text clipped - 7 lines]
> What is the more correct way to call the data function once and fill
> all labels?
You say you have a class which retrieves all the values...
So just instantiate the class and then populate the labels e.g.
MyClass myClass = new MyClass();
MyLabel1.Text = myClass.Value1.ToString();
MyLabel2.Text = myClass.Value2.ToString();
etc.
> Should I use a custom data source. How can I do that?
Why do you need one...?

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net