【发布时间】:2016-09-07 16:14:17
【问题描述】:
我有一个图书数据库(现在总共 2 本书),其中每本书我都有一个名为“图像”的行,其中包含图像的名称。 例如。 cprog.jpeg 和 asm.jpeg
使用转发器,我可以显示书籍信息,如姓名、作者等。但我不知道如何让图像显示。图像存储在 images 文件夹中。
这是aspx的问题吗?因为,它可以很好地显示书名和描述。
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "BookName") %>
<hr>
<%# DataBinder.Eval(Container.DataItem, "BookDescription") %>
<td width="100px">
<p align="left">
<img src= '<%# DataBinder.Eval(Container.DataItem, "Image") %>.jpeg'
alt="" style="height:200px;width:200px;border:1px solid gray;"/>
</td>
</p>
后面的代码
String connectionString = "Data Source=" + Server.MapPath(@"~\App_Data\bookDB.db");
String selectCommand = String.Format("Select * from Book where CategoryName = '{0}'", Request.QueryString);
SQLiteConnection myConnection = new SQLiteConnection();
myConnection.ConnectionString = connectionString;
myConnection.Open();
SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(selectCommand, myConnection);
myConnection.Close();
// DataSet ds = new DataSet();
dataAdapter.Fill(ds2);
DataTable table = new DataTable();
dataAdapter.Fill(table);
Repeater1.DataSource = table;
Repeater1.DataBind();
有一次,当我运行项目时,损坏的图像出现了一秒钟然后消失了。我花了最后两天试图得到这个无济于事...... 谢谢。
【问题讨论】:
-
下次请不要等两天再问。