将文字文本块设置为仅在另一个文字文本块返回值时显示的最佳方法是什么?
这是我正在尝试构建的代码,其中包含逻辑的注释。
<!-- 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>
答案 0 :(得分:1)
在后面的代码中从数据库中检索值后,您应该分配这些值。
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;
}