c#后台获取图片文件路径,aspx接收路径后抓取图片显示在UI上如何实现
c#在后台判断数据库中数据,符合标准以某种图片显示,不符合以另一个图片显示。然后获取图片路径传送到前端aspx接收后。到指定路径抓取图片显示在UI上。
c#:
using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.OracleClient;
using System.Text;
using System.Drawing;
using traceLogWiterSpace;
using System.Web.SessionState;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string Label2;
//连接数据库
OracleConnection conn = new OracleConnection(ConfigurationManager.ConnectionStrings["JVRPT"].ConnectionString);
traceLogWiterClass traceLogWiter = new traceLogWiterClass();
try
{
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
DataSet ds1 = new DataSet();
StringBuilder sql = new StringBuilder();
//PKG OUT
// string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "images" + @"\person_info.jpg";//获取图片路径
MyList.DataSource = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "images" + @"\person_info.jpg";//获取图片路径
MyList.DataBind();
sql.AppendLine("select round(KPIVALUE/1000000,0),'02 PKG OUT' DATA1 from KPI_YIELDRATEMASTER");
sql.AppendLine("where period=to_char(sysdate-1,'YYYY')");
sql.AppendLine("and month = SUBSTR(to_char(sysdate-1,'YYYYMM'),5,2)");
sql.AppendLine("and kpitype='PKG_1G_EQ'");
sql.AppendLine("and kpiitem='Reality'");
//traceLogWiter.userErrorLog(Request, Session, sql.ToString());
OracleDataAdapter ora1 = new OracleDataAdapter(sql.ToString(), conn);
ora1.Fill(ds1);
if (ds1.Tables[0].Rows.Count != 0)
{
//string Label2;
Label2 = ds1.Tables[0].Rows[0][0].ToString();
int D2 = int.Parse(Label2);
if (D2 < 500)
{
Label2 = path;
}
else { Label2 = "11"; };
}
else
{
//Label2 = "N/A";
}
sql.Length = 0;
ds1.Tables.Clear();
ora1.Dispose();
}
catch (Exception ex)
{
//traceLogWiter.userErrorLog(Request,Session,ex.ToString());
}
finally
{
if (conn.State != ConnectionState.Closed)
{
conn.Close();
}
}
}
}
aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="HomePage.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>HomePage</title>
<style type="text/css">
th
{
background:#E2E2E2;
font-family:'Microsoft YaHei';
font-size:14pt;
font-weight: bold;
color:#0067AC;
}
tr,td
{
text-align: center;
color:#0070C0;
font-size:12pt;
}
.style1
{
width: 66px;
}
.style2
{
width: 66px;
height: 30px;
}
.style3
{
height: 30px;
}
.style4
{
width: 66px;
height: 80px;
}
.style5
{
height: 80px;
}
</style>
</head>
<body style="margin:0px; padding:0px;">
<form id="form1" runat="server" >
<div>
<table style="width: 965px;height:415px;margin:0px;font-family: 'Microsoft YaHei'; border-style:solid; border-color:#F5FFE8;background-image:url(../../images/2.jpg)"
cellspacing="0" border="7px" rules="rows">
<th class="style1">工厂</th>
<th><font color =="#000000">PKG<span style="font-family:'Microsoft YaHei';font-size:18pt;"></font><br />
</span></th>
<th><font color =="#000000">TEST<span style="font-family:'Microsoft YaHei';font-size:18pt;"></font><br />
</span></th>
<th><font color =="#000000">MOD_A<span style="font-family:'Microsoft YaHei';font-size:18pt;"></font><br />
</span></th>
<th><font color =="#000000">MOD_T<span style="font-family:'Microsoft YaHei';font-size:18pt;"></font><br />
</span></th>
<th><font color =="#000000"><span style="font-family:'Microsoft YaHei';font-size:18pt;"></font><br />
</span></th>
<tr >
<td style="font-family: 微软雅黑; font-size: 16pt; " class="style4"><font color =="#000000">生产量</font></td>
<td class="style5">QC EVI GATE: <asp:Image runat="server" ImageUrl='<%#DataBinder.Eval(Container.DataItem,"MyList")%>'/>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
报错有多种错误,尝试其他方法也没实现。我觉得自己错在接收路径数据错误。
不知道怎么修正。请教各位大神们帮忙看下。怎么实现~不甚感激!!!!! c# 获取路径aspx显示图片 --------------------编程问答-------------------- --------------------编程问答-------------------- MyList.DataSource = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "images" + @"\person_info.jpg";//获取图片路径
绑定数据是个字符串???这什么意思 --------------------编程问答-------------------- 除
补充:.NET技术 , ASP.NET