Differences Between......

Discussion in 'ASP .Net' started by rn5a@rediffmail.com, Apr 19, 2007.

  1. Guest

    Assuming that a DataGrid gets populated by a database column named
    RegDate using a DataSet, what's the difference between

    <%# DataBinder.Eval(Container.DataItem, "RegDate") %>

    &

    <%# Container.DataItem("RegDate") %>

    If I am not wrong, the former can be used to format the output like
    for e.g.

    <%# DataBinder.Eval(Container.DataItem, "RegDate", "{0:d}") %>
    , Apr 19, 2007
    #1
    1. Advertising

  2. wrote:
    > Assuming that a DataGrid gets populated by a database column named
    > RegDate using a DataSet, what's the difference between
    >
    > <%# DataBinder.Eval(Container.DataItem, "RegDate") %>
    >
    > &
    >
    > <%# Container.DataItem("RegDate") %>
    >
    > If I am not wrong, the former can be used to format the output like
    > for e.g.
    >
    > <%# DataBinder.Eval(Container.DataItem, "RegDate", "{0:d}") %>
    >


    The Eval method uses reflection to read the "RegDate" item from the
    Container.DataItem object, so the result is the same.

    You can use formatting when reading the value directly also:

    <%# String.Format("{0:d}", Container.DataItem("RegDate")) %>

    --
    Göran Andersson
    _____
    http://www.guffa.com
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Apr 19, 2007
    #2
    1. Advertising

  3. And DataBinder.Eval is a performance hit. As Göran says, it uses reflection
    to determine the type, and reflection is a more intensive activity. If you
    can avoid using the Eval method, do it as it will help boost performance of
    your web app slightly.


    --
    Hope this helps,
    Mark Fitzpatrick
    Former Microsoft FrontPage MVP 199?-2006

    <> wrote in message
    news:...
    > Assuming that a DataGrid gets populated by a database column named
    > RegDate using a DataSet, what's the difference between
    >
    > <%# DataBinder.Eval(Container.DataItem, "RegDate") %>
    >
    > &
    >
    > <%# Container.DataItem("RegDate") %>
    >
    > If I am not wrong, the former can be used to format the output like
    > for e.g.
    >
    > <%# DataBinder.Eval(Container.DataItem, "RegDate", "{0:d}") %>
    >
    Mark Fitzpatrick, Apr 19, 2007
    #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. Rick
    Replies:
    0
    Views:
    950
  2. Rick
    Replies:
    0
    Views:
    868
  3. Carl Prothman [MVP]
    Replies:
    0
    Views:
    2,302
    Carl Prothman [MVP]
    Jul 14, 2003
  4. Home_Job_opportunity
    Replies:
    0
    Views:
    485
    Home_Job_opportunity
    Jan 8, 2009
  5. Home_Job_opportunity
    Replies:
    0
    Views:
    569
    Home_Job_opportunity
    Jan 14, 2009
Loading...

Share This Page