Link to home
Start Free TrialLog in
Avatar of lrdchelp
lrdchelpFlag for United States of America

asked on

ASP.NET datalist--add bold to one field and do not display empty fields

I have an asp classic web site that I am now recreating in ASP.Net 4.6 using Visual Studio 2013 and am having problems with what should be a simple datalist.  I need to make the first field bold and I also do not want to display database fields that are empty.  I tried using literal controls but when I got the bold to work, the code was displayed instead of the data.   I would appreciate any advice. I am attaching the code below. --Shari

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="newsawards.aspx.cs" Inherits="LRDCNew.WebForm1" %>

<!DOCTYPE html>
<asp:literal runat="server"></asp:literal>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSourceNewsAwards" RepeatLayout="Flow" ShowFooter="False" ShowHeader="False">
            <ItemTemplate>
               
                <asp:Label ID="aw_descriptionLabel" runat="server" Text=<b>'<%# Eval("aw_description") %>'</b> />
                <br />

                <asp:Label ID="aw_display_dateLabel" runat="server" Text='<%# Eval("aw_display_date") %>' />
                <br />
               
                <asp:Label ID="aw_sourceLabel" runat="server" Text='<%# Eval("aw_source") %>' />
                <br />
              
                <asp:Label ID="aw_urlLabel" runat="server" Text='<%# Eval("aw_url") %>' />
                <br />
            
                <asp:Label ID="aw_pdfLabel" runat="server" Text='<%# Eval("aw_pdf") %>' />
                <br />
<br />
            </ItemTemplate>
        </asp:DataList>
        <asp:SqlDataSource ID="SqlDataSourceNewsAwards" runat="server" ConnectionString="<%$ ConnectionStrings:lrdc_dbConnectionString2 %>" SelectCommand="SELECT [aw_description], [aw_display_date], [aw_source], [aw_url], [aw_pdf] FROM [AWARDS] ORDER BY [aw_event_date]" OnSelecting="SqlDataSourceNewsAwards_Selecting"></asp:SqlDataSource>
    </div>
    </form>
</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lrdchelp

ASKER

Thank you!  That answers both questions.