Page.DataBind()

L

lbolognini

Hi all,

I've chosen to render localized messages in my web app with using
databind. Every string has something like this:

<label id="foo" text='<%# getText(LangID, MessageCode) %>'></label>

getText is just a static method we use to retrieve the strings from the
db by populating a DataReader.

We chose not tu use the new ASP.NET 2 localization features because it
stores everything in XML and we preferred mantaining our localized
string in a db.

Performance bottlenecks could also be worked-around by placing a
DataSet with the localized strings for the most used languages
(English, Spanish, German, Italian, French, etc...).

My question is: when I call Page.DataBind() how many roundtrips to the
database are performed? Is it one for every control or just one for the
whole page?

Do you see any shortcomings with this approach?

Thanks,
Lorenzo
 
K

Karl Seguin

If you're database call is happening in getText, that is, you are opening a
connection, getting the single value and closing the connection, then you'll
get a db hit every time you see getText. Of course, you could easily
measure this by (a) debugging your code or (b) profiling your database.

it makes more sense to cache the localized information in a
namevaluecollection. Check if the cache exists, if not, get allstrings from
database and store in namevaluecollection which is then cached...

Karl
 
L

lbolognini

Karl said:
If you're database call is happening in getText, that is, you are opening a
connection, getting the single value and closing the connection, then you'll
get a db hit every time you see getText. Of course, you could easily
measure this by (a) debugging your code or (b) profiling your database.

it makes more sense to cache the localized information in a
namevaluecollection. Check if the cache exists, if not, get allstrings from
database and store in namevaluecollection which is then cached...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)

Hi Karl,

thanks for your reply... nice site too!

Lorenzo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top