Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 当没有记录值时,超链接替换链接文本_Asp.net - Fatal编程技术网

Asp.net 当没有记录值时,超链接替换链接文本

Asp.net 当没有记录值时,超链接替换链接文本,asp.net,Asp.net,我正在使用VB.NET。基本上,如果数据库中没有文件路径记录,我会试图隐藏链接,但我无法找到它 这是我在DetailsView的EditItemTemplate中的代码: <EditItemTemplate > <div style="display:inline; width:40%; "> <asp:HyperLink ID="linkFileUploaded" runat=server NavigateUrl='<%#Eval("

我正在使用VB.NET。基本上,如果数据库中没有文件路径记录,我会试图隐藏链接,但我无法找到它

这是我在DetailsView的EditItemTemplate中的代码:

<EditItemTemplate >
    <div style="display:inline; width:40%; ">
        <asp:HyperLink ID="linkFileUploaded" runat=server NavigateUrl='<%#Eval("FilePath")%>' Visible="False" >Attached File</asp:HyperLink> 
    </div>
 </EditItemTemplate>

附件
我要做的是,如果Eval(“FilePath”)=,则显示文本“无附加文件”


请帮忙。谢谢

它是一个超链接,因此最好隐藏它-根据文件路径是否为空动态设置visible属性:

Visible='<%# If(Eval("FilePath").ToString() Is DBNull.Value, False, True) %>'
Visible=''
例如:

<asp:HyperLink ID="linkFileUploaded" runat=server NavigateUrl='<%#Eval("FilePath")%>' Visible='<%# If(Eval("FilePath").ToString() Is DBNull.Value, False, True) %>' >Attached File</asp:HyperLink>
附加文件
然后有一个标签,显示FilePath为空时:

<asp:Label ID="MyLabel" runat="server" Text='No Attached File'
    Visible='<%# If(Eval("FilePath").ToString() Is DBNull.Value, True, False) %>'></asp:Label>

它们都会进入您的EditItemTemplate中:

<EditItemTemplate>
    <div style="display:inline; width:40%; ">
    <asp:HyperLink ID="linkFileUploaded" runat=server NavigateUrl='<%#Eval("FilePath")%>' Visible='<%# If(Eval("FilePath").ToString() Is DBNull.Value, False, True) %>' >Attached File</asp:HyperLink>
<asp:Label ID="MyLabel" runat="server" Text='No Attached File'
    Visible='<%# If(Eval("FilePath").ToString() Is DBNull.Value, True, False) %>'></asp:Label>
    </div>
 </EditItemTemplate>

附件

我收到此错误“Leading.”或“!”只能出现在“With”语句中。对于“”是因为我使用VB.NET吗?是的,我已将其更改为VB.NET语法。我将“NOT”替换为“!“这很有效。非常感谢你的帮助。