Hi All.

I am developing a website in asp.net 3.5.

I am trying to retrieve records from a database and display. Before each record I want to dispaly the title of the record such as: "Department Accounts" where the word accounts is from the database.

However, if a record is null such as no mobile telephone number my page is displaying the word "Mobile" but as the record is null there is no record to show. This is no good.

I want to test if the record is null and if it is display nothing. If it is display the record along with the title.

<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1">
        
        <LayoutTemplate>
                <asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
        </LayoutTemplate>
        
            <ItemTemplate>
            <div style="width:100%; height:auto; padding:10px; background-color:#efefef; clear:both; float:left; border:1px solid #c5c5c5; margin:5px;">        
            <%#Eval("staff_name")%> <br />
            Department: <%#Eval("department")%> <br />
            Title: <%#Eval("job_title")%> <br />
            Telephone: <%#Eval("telephone")%> <br />
            </ItemTemplate>
       </asp:ListView>

Somthing like this:


If Database Record(Mobile) is null
Display ""
else
Display "<p>Mobile Number" + Record(Mobile)</p>

Any help is greatly appreciated!

Thanks, Paul

select 
isnull(mobile,'No record')

from table
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.