Inline Evaluation of a DataBound Value within a Repeater Item Template

Discussion in 'ASP .Net' started by Michael Wendel, Sep 1, 2005.

  1. Ok. I have been banging my head against the wall trying to figure out
    how this piece of display logic can be implemented:

    <% if (DataBinder.Eval(Container.DataItem, "SomeItem") != "SomeValue")
    { %>
    HTML DISPLAY BLOCK
    <% } %>

    The reason I would prefer to do it this way is:
    (1) Easier management by the HTML producers/designers
    (2) It seems pointless to create yet another control for a single
    table row or even table cell depending upon the case of HTML formatted
    data.

    In the future I won't need this but I am dealing with a pre-existing
    code base that I don't have the time to change.



    -----------------------------------
    "Integrity is doing the right thing,
    even if nobody is watching."
    -----------------------------------
    "Normally we do not so much
    look at things as overlook them."
    Michael Wendel, Sep 1, 2005
    #1
    1. Advertising

  2. On Thu, 01 Sep 2005 10:11:23 -0500, Michael Wendel <>
    wrote:

    > Ok. I have been banging my head against the wall trying to figure out
    > how this piece of display logic can be implemented:
    >
    > <% if (DataBinder.Eval(Container.DataItem, "SomeItem") != "SomeValue")
    > { %>
    > HTML DISPLAY BLOCK
    > <% } %>
    >
    > The reason I would prefer to do it this way is:
    > (1) Easier management by the HTML producers/designers
    > (2) It seems pointless to create yet another control for a single
    > table row or even table cell depending upon the case of HTML formatted
    > data.
    >
    > In the future I won't need this but I am dealing with a pre-existing
    > code base that I don't have the time to change.
    >
    >
    >
    > -----------------------------------
    > "Integrity is doing the right thing,
    > even if nobody is watching."
    > -----------------------------------
    > "Normally we do not so much
    > look at things as overlook them."


    wrap the HTML block in a asp:panel or a similar container control, set its
    Visible property to a databound expression that is your If expression

    <asp:panel ... Visible='<%# DataBinder.Eval(Container.DataItem,
    "SomeItem") != "SomeValue" %>' ...>
    HTML DISPLAY BLOCK
    </asp:panel>

    I belive this should work...regardless, the DataBinder.Eval only makes
    sense inside of a binding statement/expression, not in a script block...

    --
    craig
    Microsoft MVP - ASP/ASP.NET
    Craig Deelsnyder, Sep 2, 2005
    #2
    1. Advertising

  3. I'll check it out.

    Thanks,

    Michael


    On Fri, 02 Sep 2005 11:17:58 -0500, "Craig Deelsnyder"
    <cdeelsny@no_spam_4_meyahoo.com> wrote:

    >On Thu, 01 Sep 2005 10:11:23 -0500, Michael Wendel <>
    >wrote:
    >
    >> Ok. I have been banging my head against the wall trying to figure out
    >> how this piece of display logic can be implemented:
    >>
    >> <% if (DataBinder.Eval(Container.DataItem, "SomeItem") != "SomeValue")
    >> { %>
    >> HTML DISPLAY BLOCK
    >> <% } %>
    >>
    >> The reason I would prefer to do it this way is:
    >> (1) Easier management by the HTML producers/designers
    >> (2) It seems pointless to create yet another control for a single
    >> table row or even table cell depending upon the case of HTML formatted
    >> data.
    >>
    >> In the future I won't need this but I am dealing with a pre-existing
    >> code base that I don't have the time to change.
    >>
    >>
    >>
    >> -----------------------------------
    >> "Integrity is doing the right thing,
    >> even if nobody is watching."
    >> -----------------------------------
    >> "Normally we do not so much
    >> look at things as overlook them."

    >
    >wrap the HTML block in a asp:panel or a similar container control, set its
    >Visible property to a databound expression that is your If expression
    >
    ><asp:panel ... Visible='<%# DataBinder.Eval(Container.DataItem,
    >"SomeItem") != "SomeValue" %>' ...>
    > HTML DISPLAY BLOCK
    ></asp:panel>
    >
    >I belive this should work...regardless, the DataBinder.Eval only makes
    >sense inside of a binding statement/expression, not in a script block...


    -----------------------------------
    "Integrity is doing the right thing,
    even if nobody is watching."
    -----------------------------------
    "Normally we do not so much
    look at things as overlook them."
    Michael Wendel, Sep 6, 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. darrel
    Replies:
    8
    Views:
    599
    darrel
    Nov 30, 2004
  2. Rod  Snyder
    Replies:
    1
    Views:
    3,552
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Feb 17, 2005
  3. rodchar
    Replies:
    0
    Views:
    379
    rodchar
    Nov 26, 2007
  4. mark4asp
    Replies:
    1
    Views:
    576
    mark4asp
    Dec 3, 2007
  5. Manu
    Replies:
    0
    Views:
    159
Loading...

Share This Page