Hiding the anchor tag in asp.net 1.1 based on condition - help me

Discussion in 'ASP .Net' started by vishnu, Dec 1, 2006.

  1. vishnu

    vishnu Guest

    Hi,

    I have a link that is coming from the database.Now if the link is
    empty i dont want to display in datalist .How can i do that?

    <td><asp:DataList id="DataList1" Runat="server"
    RepeatDirection="Horizontal" RepeatColumns="3" CellPadding="5"
    CellSpacing="2" Width="100%" EnableViewState="False">
    <itemtemplate>
    <b>
    <%# DataBinder.Eval(Container.DataItem, "FIRST_NAME") %>
    <%# DataBinder.Eval(Container.DataItem, "MIDDLE_NAME") %>
    <%# DataBinder.Eval(Container.DataItem, "LAST_NAME") %>
    </b>
    <br>
    <%# DataBinder.Eval(Container.DataItem, "ADDRESS1") %>
    <%# DataBinder.Eval(Container.DataItem, "ADDRESS2") %>
    <br>
    <%# DataBinder.Eval(Container.DataItem, "CITY") %>
    <%# DataBinder.Eval(Container.DataItem, "STATE") %>
    <%# DataBinder.Eval(Container.DataItem, "ZIP_CODE") %>
    <br>
    <%# DataBinder.Eval(Container.DataItem, "TELEPHONE") %>
    <br>
    <%# DataBinder.Eval(Container.DataItem, "EMAIL") %>
    <br>
    <a id="Resume" href="<%#
    DataBinder.Eval(Container.DataItem, "BIO_RESUME") %>" name="Resume"
    Target="_blank">click here for bio/resume</a></b>
    </itemtemplate>
    </asp:DataList></td>


    Thanks,
    Vishnu
    vishnu, Dec 1, 2006
    #1
    1. Advertising

  2. A quick solution is in your query return a # when the url field is
    null


    On 1 Dec 2006 11:21:11 -0800, "vishnu" <> wrote:

    >
    >Hi,
    >
    > I have a link that is coming from the database.Now if the link is
    >empty i dont want to display in datalist .How can i do that?
    >
    ><td><asp:DataList id="DataList1" Runat="server"
    >RepeatDirection="Horizontal" RepeatColumns="3" CellPadding="5"
    >CellSpacing="2" Width="100%" EnableViewState="False">
    > <itemtemplate>
    > <b>
    > <%# DataBinder.Eval(Container.DataItem, "FIRST_NAME") %>
    > <%# DataBinder.Eval(Container.DataItem, "MIDDLE_NAME") %>
    > <%# DataBinder.Eval(Container.DataItem, "LAST_NAME") %>
    > </b>
    > <br>
    > <%# DataBinder.Eval(Container.DataItem, "ADDRESS1") %>
    > <%# DataBinder.Eval(Container.DataItem, "ADDRESS2") %>
    > <br>
    > <%# DataBinder.Eval(Container.DataItem, "CITY") %>
    > <%# DataBinder.Eval(Container.DataItem, "STATE") %>
    > <%# DataBinder.Eval(Container.DataItem, "ZIP_CODE") %>
    > <br>
    > <%# DataBinder.Eval(Container.DataItem, "TELEPHONE") %>
    > <br>
    > <%# DataBinder.Eval(Container.DataItem, "EMAIL") %>
    > <br>
    > <a id="Resume" href="<%#
    >DataBinder.Eval(Container.DataItem, "BIO_RESUME") %>" name="Resume"
    >Target="_blank">click here for bio/resume</a></b>
    > </itemtemplate>
    > </asp:DataList></td>
    >
    >
    >Thanks,
    >Vishnu

    --

    Bits.Bytes.
    http://bytes.thinkersroom.com
    Rad [Visual C# MVP], Dec 1, 2006
    #2
    1. Advertising

  3. vishnu

    vishnu Guest

    Hi,
    Thanks for your suggestion. I have written a function to handle this.

    public string ShowLink(object row)
    {
    string resume=DataBinder.Eval(row,"BIO_RESUME") as string;
    if(resume==null || resume.Trim().Length==0)
    {
    return "<p>No Data</p>";

    }
    else
    return "<a href='<%#Container.DataItem %>' Target="_blank"'>" +
    + "View Bio Resume</a>";
    }


    Please let me know if this works.

    Thanks,
    Vishnu

    Rad [Visual C# MVP] wrote:
    > A quick solution is in your query return a # when the url field is
    > null
    >
    >
    > On 1 Dec 2006 11:21:11 -0800, "vishnu" <> wrote:
    >
    > >
    > >Hi,
    > >
    > > I have a link that is coming from the database.Now if the link is
    > >empty i dont want to display in datalist .How can i do that?
    > >
    > ><td><asp:DataList id="DataList1" Runat="server"
    > >RepeatDirection="Horizontal" RepeatColumns="3" CellPadding="5"
    > >CellSpacing="2" Width="100%" EnableViewState="False">
    > > <itemtemplate>
    > > <b>
    > > <%# DataBinder.Eval(Container.DataItem, "FIRST_NAME") %>
    > > <%# DataBinder.Eval(Container.DataItem, "MIDDLE_NAME") %>
    > > <%# DataBinder.Eval(Container.DataItem, "LAST_NAME") %>
    > > </b>
    > > <br>
    > > <%# DataBinder.Eval(Container.DataItem, "ADDRESS1") %>
    > > <%# DataBinder.Eval(Container.DataItem, "ADDRESS2") %>
    > > <br>
    > > <%# DataBinder.Eval(Container.DataItem, "CITY") %>
    > > <%# DataBinder.Eval(Container.DataItem, "STATE") %>
    > > <%# DataBinder.Eval(Container.DataItem, "ZIP_CODE") %>
    > > <br>
    > > <%# DataBinder.Eval(Container.DataItem, "TELEPHONE") %>
    > > <br>
    > > <%# DataBinder.Eval(Container.DataItem, "EMAIL") %>
    > > <br>
    > > <a id="Resume" href="<%#
    > >DataBinder.Eval(Container.DataItem, "BIO_RESUME") %>" name="Resume"
    > >Target="_blank">click here for bio/resume</a></b>
    > > </itemtemplate>
    > > </asp:DataList></td>
    > >
    > >
    > >Thanks,
    > >Vishnu

    > --
    >
    > Bits.Bytes.
    > http://bytes.thinkersroom.com
    vishnu, Dec 1, 2006
    #3
  4. vishnu

    vishnu Guest

    Hi,
    Thanks for your suggestion. I have written a function to handle this.

    public string ShowLink(object row)
    {
    string resume=DataBinder.Eval(row,"BIO_RESUME") as string;
    if(resume==null || resume.Trim().Length==0)
    {
    return "<p>No Data</p>";

    }
    else
    return "<a href='<%#Container.DataItem %>' Target="_blank"'>" +
    + "View Bio Resume</a>";
    }


    Please let me know if this works.

    Thanks,
    Vishnu

    Rad [Visual C# MVP] wrote:
    > A quick solution is in your query return a # when the url field is
    > null
    >
    >
    > On 1 Dec 2006 11:21:11 -0800, "vishnu" <> wrote:
    >
    > >
    > >Hi,
    > >
    > > I have a link that is coming from the database.Now if the link is
    > >empty i dont want to display in datalist .How can i do that?
    > >
    > ><td><asp:DataList id="DataList1" Runat="server"
    > >RepeatDirection="Horizontal" RepeatColumns="3" CellPadding="5"
    > >CellSpacing="2" Width="100%" EnableViewState="False">
    > > <itemtemplate>
    > > <b>
    > > <%# DataBinder.Eval(Container.DataItem, "FIRST_NAME") %>
    > > <%# DataBinder.Eval(Container.DataItem, "MIDDLE_NAME") %>
    > > <%# DataBinder.Eval(Container.DataItem, "LAST_NAME") %>
    > > </b>
    > > <br>
    > > <%# DataBinder.Eval(Container.DataItem, "ADDRESS1") %>
    > > <%# DataBinder.Eval(Container.DataItem, "ADDRESS2") %>
    > > <br>
    > > <%# DataBinder.Eval(Container.DataItem, "CITY") %>
    > > <%# DataBinder.Eval(Container.DataItem, "STATE") %>
    > > <%# DataBinder.Eval(Container.DataItem, "ZIP_CODE") %>
    > > <br>
    > > <%# DataBinder.Eval(Container.DataItem, "TELEPHONE") %>
    > > <br>
    > > <%# DataBinder.Eval(Container.DataItem, "EMAIL") %>
    > > <br>
    > > <a id="Resume" href="<%#
    > >DataBinder.Eval(Container.DataItem, "BIO_RESUME") %>" name="Resume"
    > >Target="_blank">click here for bio/resume</a></b>
    > > </itemtemplate>
    > > </asp:DataList></td>
    > >
    > >
    > >Thanks,
    > >Vishnu

    > --
    >
    > Bits.Bytes.
    > http://bytes.thinkersroom.com
    vishnu, Dec 1, 2006
    #4
    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. shruds
    Replies:
    1
    Views:
    778
    John C. Bollinger
    Jan 27, 2006
  2. HockeyFan
    Replies:
    2
    Views:
    405
    HockeyFan
    Dec 7, 2006
  3. g-factor

    hiding condition with JSF tag

    g-factor, Jan 16, 2007, in forum: Java
    Replies:
    2
    Views:
    901
  4. Bill W.
    Replies:
    13
    Views:
    289
    Phillip Gawlowski
    May 9, 2011
  5. eivind

    div tag and anchor tag

    eivind, Jan 5, 2004, in forum: Javascript
    Replies:
    1
    Views:
    125
    eivind
    Jan 15, 2004
Loading...

Share This Page