在Asp.net列表视图图片没有显示到接口,但是该图像是已经在数据库
问题描述:
列表视图的代码:在Asp.net列表视图图片没有显示到接口,但是该图像是已经在数据库
<section id="service" class="bg-light paddingtop-60">
<div class="container">
<div class="row col-md-12">
<div class="col-md-3">
<asp:SqlDataSource ID="DoctorSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:eSoft_DHD_BusinessConnectionString %>"
SelectCommand="SELECT DoctorChambers.City, DoctorMains.DoctorName, DoctorMains.Title, DoctorMains.ProfileImage, DoctorMains.DoctorID FROM DoctorChambers RIGHT OUTER JOIN DoctorMains
ON DoctorChambers.DoctorMain_DoctorID = DoctorMains.DoctorID WHERE (DoctorChambers.City LIKE '%' + @City + '%') AND (DoctorMains.DoctorName LIKE '%' + @DoctorName + '%')">
<SelectParameters>
<asp:SessionParameter Name="City" SessionField="DocCity" Type="String"/>
<asp:SessionParameter Name="DoctorName" SessionField="DocSession" Type="String"/>
</SelectParameters>
</asp:SqlDataSource>
<div class="col-md-9">
<asp:ListView ID="DoctorListView" runat="server" DataSourceID="DoctorSqlDataSource">
<ItemTemplate>
<table class ="table table-bordered">
<tr class="bg-gray">
<td class ="col-md-2">
<asp:Image ID="ProfileImage" runat="server" Width="120" Height="120" CssClass="person img-circle" ImageUrl='<%# "PublicPages/Search.aspx?ImageID="+Eval("DoctorId") %>' />
<%--<asp:Image ID="ProfileImage" runat="server" Width="120" Height="120" CssClass="person img-circle" ImageUrl=' ~/PublicPages/Search.aspx?ImageID=<%#Eval("DoctorId") %>' />--%>
</td>
<td class="col-md-4">
<asp:Label ID="DoctorNameLabel" runat="server" Text='<%# Eval("DoctorName") %>' />
</td>
<td class="col-md-6">
<asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
</td>
<td class="col-md-8">
<asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City") %>' />
</td>
</tr>
</table>
</ItemTemplate>
<AlternatingItemTemplate>
<table class ="table table-bordered">
<tr style="">
<td class ="col-md-2">
<asp:Image ID="ProfileImage" runat="server" Width="120" Height="120" CssClass="person img-circle" ImageUrl='<%# "PublicPages/Search.aspx?ImageID="+Eval("DoctorId") %>' />
<%-- <asp:Image ID="ProfileImage" runat="server" Width="120" Height="120" CssClass="person img-circle" ImageUrl=' ~/PublicPages/Search.aspx?ImageID=<%#Eval("DoctorId") %>' />--%>
</td>
<td class="col-md-4">
<asp:Label ID="DoctorNameLabel" runat="server" Text='<%# Eval("DoctorName") %>' />
</td>
<td class="col-md-6">
<asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' />
</td>
<td class="col-md-8">
<asp:Label ID="CityLabel" runat="server" Text='<%# Eval("City") %>' />
</td>
</tr>
</table>
</AlternatingItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
</asp:ListView>
</div>
</div>
</div>
</div>
</section>
答
此问题得到解决。此问题是由于缺少Data BindingSource和连接字符串而创建的。
当你进入'PublicPages/Search.aspx?ImageID =“+ Eval(”DoctorId“)'(带有一个合适的医生ID)_?你会得到一个图像吗?如果没有,出了什么问题?不显示“是用户对问题的描述,您是程序员,请给我们一个程序员的描述并解释您所做的调试以及您遇到的具体错误或问题。 – ADyson
已解决此问题。问题是由于缺少Data BindingSource和错误的连接字符串而创建的。 –
已解决此问题。此问题是由于缺少Data BindingSource和错误的连接字符串而创建的。 –