asp.net读取ACCESS数据库里的图片不显示
我的后台代码是protectedvoidPage_Load(objectsender,EventArgse){if(!Page.IsPostBack){stringcon...
我的后台代码是protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string connstr = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(@"admin.mdb");
OleDbConnection conn = new OleDbConnection(connstr);
conn.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "Select top 8 * from chanpin where leibieid = 1 ";
cmd.Connection = conn;
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
this.rt.DataSource = ds;
this.rt.DataBind();
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
前台代码:
<asp:DataList ID="rt" runat="server" RepeatDirection="Horizontal"
RepeatColumns="4">
<ItemTemplate>
<div style="width:199px; height:165px; float:left"><div style="width:160px; height:120px; margin:0 auto;"><img src='<%#Eval("ps1").ToString() %>' width="160px" height="120px" /></div>
<div style="width:180; height:15px; margin: 0 auto; text-align:center"><%#DataBinder.Eval(Container.DataItem,"pinpai") %></div>
<div style="width:180px; height:15px; margin:0 auto; text-align:center"><%#DataBinder.Eval(Container.DataItem,"xinghao1") %></div></div>
</ItemTemplate>
</asp:DataList>
能告诉我怎么设成模版列吗? 展开
{
if (!Page.IsPostBack)
{
string connstr = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath(@"admin.mdb");
OleDbConnection conn = new OleDbConnection(connstr);
conn.Open();
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "Select top 8 * from chanpin where leibieid = 1 ";
cmd.Connection = conn;
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
this.rt.DataSource = ds;
this.rt.DataBind();
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
}
前台代码:
<asp:DataList ID="rt" runat="server" RepeatDirection="Horizontal"
RepeatColumns="4">
<ItemTemplate>
<div style="width:199px; height:165px; float:left"><div style="width:160px; height:120px; margin:0 auto;"><img src='<%#Eval("ps1").ToString() %>' width="160px" height="120px" /></div>
<div style="width:180; height:15px; margin: 0 auto; text-align:center"><%#DataBinder.Eval(Container.DataItem,"pinpai") %></div>
<div style="width:180px; height:15px; margin:0 auto; text-align:center"><%#DataBinder.Eval(Container.DataItem,"xinghao1") %></div></div>
</ItemTemplate>
</asp:DataList>
能告诉我怎么设成模版列吗? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询