0
我試圖從文件夾中檢索圖像並將其顯示在我的數據列表中,但不幸的是圖像未顯示。asp.net,從文件夾綁定datalist圖像
當我運行代碼並檢查元素時,它顯示正確的路徑,但圖像不顯示。
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
謝謝JNYRanger,我剛剛粘貼了上面的主要datalist asp代碼,以避免混淆和混亂 –