【发布时间】:2015-05-04 14:43:31
【问题描述】:
我正在尝试从文件夹中检索图像并将其显示在我的数据列表中,但不幸的是该图像未显示。
当我运行代码并检查元素时,它会显示正确的路径,但图像没有显示。
asp 代码
<asp:DataList ID="DataList1" runat="server" GridLines="Horizontal">
<ItemTemplate>
<table class="auto-style1">
<tr>
<td class="auto-style2" rowspan="6">
<img src= "<%# Eval(("Photo")) %>" />
</td>
</ItemTemplate>
</asp:DataList>
C# 代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
namespace CARSEZEE2015
{
public partial class WebForm3: System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=server name;Initial Catalog=catalogname;User ID=id;Password=password");
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select * from DB";
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
DataList1.DataSource = dt;
DataList1.DataBind();
con.Close();
}
'
【问题讨论】:
-
我格式化了你的代码,看起来你缺少很多你的 asp 代码...
-
谢谢 JNYRanger,我刚刚粘贴了上面的主要数据列表 asp 代码,以避免混淆和混乱