我需要显示数据库表中的多个图像并将其绑定到转发器,我该怎么做呢?
这是我当前的代码,但我不知道如何继续显示图像
以下是我将数据加载到中继器的方法:
public void loadNoofNewJobsCompany()
{
DateTime lastlogged = Convert.ToDateTime(Session["LastLoginstaff"]);
string sqlStr = "SELECT * FROM Job ";
sqlStr += "WHERE ";
sqlStr += "UpdatedDateCmpRep <= @loggedin";
SqlCommand cmd = new SqlCommand(sqlStr, cnn);
cmd.Parameters.AddWithValue("@loggedin", lastlogged);
try
{
cnn.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
Label2.Text = dt.Rows.Count.ToString();
PagedDataSource pgdsc = new PagedDataSource();
pgdsc.DataSource = dt.DefaultView;
repeater1.DataSource = pgdsc;
repeater1.DataBind();
}
catch (Exception ex)
{
Response.Write("Error: " + ex.Message);
}
finally
{
if (cnn != null)
{
cnn.Close();
}
}
}
这是中继器:
<asp:Repeater ID="repeater1" runat="server">
<ItemTemplate>
<div class="boxgrid caption">
<%--<img src="../../img/google.png" style="text-align:center"/>--%>
<div class="cover boxcaption">
<p>
<a href='../Job/ViewJobDetail.aspx?ID=<%# DataBinder.Eval(Container.DataItem, "JobID")%>' class="headerlink">
<%# getTitle(Eval("JobName").ToString()) %>
</a>
</p>
<p>
Salary Range:
<%# DataBinder.Eval(Container.DataItem, "JobSalaryRange")%>
</p>
... (more stuff - not relevant here) .....
</div>
</div>
</ItemTemplate>
</asp:Repeater>