Asp.net 基于另一个文字值设置文字的显示

Asp.net 基于另一个文字值设置文字的显示,asp.net,Asp.net,将文本块设置为仅在另一个文本块返回值时显示的最佳方法是什么 下面是我试图构建的代码,其中包含逻辑的注释 <!-- Will be shown if there is content in the DB --> <asp:Literal id="letter_to_zelda" runat="server"></asp:Literal> <!-- Will be also shown if there is content in the db, but

将文本块设置为仅在另一个文本块返回值时显示的最佳方法是什么

下面是我试图构建的代码,其中包含逻辑的注释

<!-- Will be shown if there is content in the DB -->
<asp:Literal id="letter_to_zelda" runat="server"></asp:Literal>

<!-- Will be also shown if there is content in the db, but 
     I only want to show it if the line above had no content to display -->
<asp:Literal id="letter_to_link" runat="server"></asp:Literal>

在代码隐藏中从数据库检索值后,应分配这些值

letter_to_zelda.Text = ValueFromDb;
if(String.IsNullOrEmpty(ValueFromDb))
{
    //if content is not static, assign it
    letter_to_link.Text = LetterText;
    letter_to_link.Visible = true;
}

谢谢分享帕斯卡的代码。不幸的是,在这种情况下C代码是不可访问的。您知道在.aspx文件中实现这一点的方法吗?您也可以在aspx中编写代码,但如何从数据库中获取以及从何处获取?aspx文件是一个电子邮件模板,它根据用户满足的特定条件从SQL DB中提取内容。不幸的是,aspx不是很智能,并且正在显示来自DB的多个内容块。我希望aspx在第一个块有内容的情况下不显示第二个块。我不太了解使用的模板,但您可以将c代码嵌入到aspx中,方法是将其放在
之间。非常感谢Pascal,我会发回结果:)