Dynamically set FormView

Discussion in 'ASP .Net' started by gsauns, Oct 25, 2007.

  1. gsauns

    gsauns Guest

    I have a FormView control bound to a data source.
    Right now, I am working with the regular old ItemTemplate. I have one
    field that I would like to set a label's Text property equal to (easy
    enough with <%# Eval("Field") %>), UNLESS that field is blank/null,
    then I would like to set it to some text, like "None Specified".

    I've been trying to set the label's Text dynamically, but haven't had
    any luck. Anyone have a method I could use to accomplish this? (Code-
    behind is C#)

    gsauns, Oct 25, 2007
    1. Advertisements

  2. gsauns

    gsauns Guest

    To anyone that needs it, here was the eventual solution. I set the
    label's Text property to:

    <%# Eval("Field").ToString().Equals(string.Empty) ? "None Specified" :
    Eval("Field") %>
    gsauns, Oct 25, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.