Page.DataBind()

Discussion in 'ASP .Net' started by lbolognini@gmail.com, Sep 1, 2005.

  1. Guest

    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
     
    , Sep 1, 2005
    #1
    1. Advertising

  2. Karl Seguin Guest

    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!)


    <> wrote in message
    news:...
    > 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
    >
     
    Karl Seguin, Sep 1, 2005
    #2
    1. Advertising

  3. Guest

    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
     
    , Sep 1, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Klemt
    Replies:
    1
    Views:
    418
    Cowboy \(Gregory A. Beamer\)
    Jan 14, 2004
  2. =?Utf-8?B?SmltIEhlYXZleQ==?=

    Page.DataBind()

    =?Utf-8?B?SmltIEhlYXZleQ==?=, May 1, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,030
    Joe Fallon
    May 3, 2004
  3. Martin
    Replies:
    1
    Views:
    445
    =?Utf-8?B?RGVtZXRyaQ==?=
    Sep 22, 2004
  4. =?Utf-8?B?RXJpYyBMaXByYW5kaQ==?=

    DataBind() on a content page

    =?Utf-8?B?RXJpYyBMaXByYW5kaQ==?=, Mar 28, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    492
    =?Utf-8?B?RXJpYyBMaXByYW5kaQ==?=
    Mar 28, 2006
  5. Michael
    Replies:
    0
    Views:
    247
    Michael
    Dec 29, 2003
Loading...

Share This Page