C# 如何在asp.NETC的网格模板中给出if-else条件?
我写了下面几行代码C# 如何在asp.NETC的网格模板中给出if-else条件?,c#,asp.net,c#-4.0,C#,Asp.net,C# 4.0,我写了下面几行代码 <asp:TemplateField HeaderText="Marketing Document / URL" SortExpression="DocumentActualName"> <ItemTemplate> <%# (String.IsNullOrEmpty(Eval("DocumentActualName").ToString() ) ? %>
<asp:TemplateField HeaderText="Marketing Document / URL" SortExpression="DocumentActualName">
<ItemTemplate>
<%# (String.IsNullOrEmpty(Eval("DocumentActualName").ToString() ) ? %>
<asp:LinkButton ID="lnkDownload" runat="server" CommandArgument='<%# DataBinder.Eval (Container.DataItem, "ProductDocument") %>'
CommandName="Download" CausesValidation="false" Text='<%# Eval("DocumentActualName") %>'> </asp:LinkButton>
<% : %>
<a id ="lnkUrl" runat="server" href='<%# Eval("URL") %>' Text='<%# Eval("URL") %>'></a>
</ItemTemplate>
</asp:TemplateField>
它不起作用了。请帮助您需要带上数据绑定标签,不能在单独的行中写入。您可以提供在if-else条件下写入上述代码的语法吗。我尝试了很多,但都失败了。我更新了我的问题。。这正是它抛出错误消息的代码无效术语“:”
href='<%#Page.ResolveUrl(Eval("URL"))%>'
<a href='<%# String.IsNullOrEmpty(Eval("File").ToString()) ? Eval("URL") : Eval("File") %>'> URL </a>