Differences Between......

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rn5a@rediffmail.com

    #1

    Differences Between......

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

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

    &

    <%# Container.DataI tem("RegDate") %>

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

    <%# DataBinder.Eval (Container.Data Item, "RegDate", "{0:d}") %>

  • =?ISO-8859-1?Q?G=F6ran_Andersson?=

    #2
    Re: Differences Between......

    rn5a@rediffmail .com wrote:
    Assuming that a DataGrid gets populated by a database column named
    RegDate using a DataSet, what's the difference between
    >
    <%# DataBinder.Eval (Container.Data Item, "RegDate") %>
    >
    &
    >
    <%# Container.DataI tem("RegDate") %>
    >
    If I am not wrong, the former can be used to format the output like
    for e.g.
    >
    <%# DataBinder.Eval (Container.Data Item, "RegDate", "{0:d}") %>
    >
    The Eval method uses reflection to read the "RegDate" item from the
    Container.DataI tem object, so the result is the same.

    You can use formatting when reading the value directly also:

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

    --
    Göran Andersson
    _____
    Göran Anderssons privata hemsida.

    Comment

    • Mark Fitzpatrick

      #3
      Re: Differences Between......

      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

      <rn5a@rediffmai l.comwrote in message
      news:1176966563 .103513.27630@q 75g2000hsh.goog legroups.com...
      Assuming that a DataGrid gets populated by a database column named
      RegDate using a DataSet, what's the difference between
      >
      <%# DataBinder.Eval (Container.Data Item, "RegDate") %>
      >
      &
      >
      <%# Container.DataI tem("RegDate") %>
      >
      If I am not wrong, the former can be used to format the output like
      for e.g.
      >
      <%# DataBinder.Eval (Container.Data Item, "RegDate", "{0:d}") %>
      >

      Comment

      Working...