Repeater - checking for null values

Discussion in 'ASP .Net' started by Jason, Sep 27, 2004.

  1. Jason

    Jason Guest

    I am using a repeater to display my search results (see
    snippet below). If the DataItem is null, I don't want to
    display the hyperlink text (Open Survey). Can I do an
    If..Then right in the aspx page to check for a null or
    blank value? I would much rather do this in the code-
    behind if possible.
    ....
    <td><asp:HyperLink NavigateUrl='<%# Databinder.Eval
    (Container.DataItem, "Survey") %>' Runat="server"
    ID="hypSurvey">Open Survey</asp:HyperLink></td>
    ....

    Thanks.
     
    Jason, Sep 27, 2004
    #1
    1. Advertising

  2. Jason

    Karl Seguin Guest

    Jason,
    You should/can do this in codebehind, hook into the ItemDataBound event of
    the repeater, it'll fire for each <itemTemplate> you'll have access to
    e.Item.DataItem which you can cast to a DataRowView (my guess is that's what
    you need). At that point you can access your fields, like

    HyperLink h = (HyperLink) e.item.FindControl("hypSurvey");
    h.visible = false;

    or something similar..

    Karl
    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Jason" <> wrote in message
    news:3aa801c4a4b4$1168dcd0$...
    > I am using a repeater to display my search results (see
    > snippet below). If the DataItem is null, I don't want to
    > display the hyperlink text (Open Survey). Can I do an
    > If..Then right in the aspx page to check for a null or
    > blank value? I would much rather do this in the code-
    > behind if possible.
    > ...
    > <td><asp:HyperLink NavigateUrl='<%# Databinder.Eval
    > (Container.DataItem, "Survey") %>' Runat="server"
    > ID="hypSurvey">Open Survey</asp:HyperLink></td>
    > ...
    >
    > Thanks.
     
    Karl Seguin, Sep 27, 2004
    #2
    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. Jimmy Crider
    Replies:
    3
    Views:
    464
    Chad Z. Hower aka Kudzu
    Feb 18, 2004
  2. Replies:
    5
    Views:
    26,735
    Mike Schilling
    Mar 29, 2006
  3. =?Utf-8?B?TWFydHluIEZld3RyZWxs?=

    VB.Net - checking for Null values in DataSets

    =?Utf-8?B?TWFydHluIEZld3RyZWxs?=, Aug 1, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    40,104
    pro.rakesh
    Aug 7, 2009
  4. Fuzzydave

    Python checking for None/Null values

    Fuzzydave, Aug 11, 2006, in forum: Python
    Replies:
    9
    Views:
    125,314
    Fuzzydave
    Aug 11, 2006
  5. Andy B
    Replies:
    2
    Views:
    327
Loading...

Share This Page