Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Page.DataBind()

Reply
Thread Tools

Page.DataBind()

 
 
lbolognini@gmail.com
Guest
Posts: n/a
 
      09-01-2005
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

 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      09-01-2005
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!)


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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
>



 
Reply With Quote
 
 
 
 
lbolognini@gmail.com
Guest
Posts: n/a
 
      09-01-2005

Karl Seguin wrote:
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments