ImageUrl='<%#" ~/Admin/Img/" +DataBinder.Eval(Container.DataItem,"img_path")%>'
后台代码是这样的:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack )
{ SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["sql"]);
string cmd = "select * from img";
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd,conn );
DataSet ds = new DataSet();
da.Fill(ds);
DataList1.DataSource = ds.Tables[0].DefaultView;
DataList1.DataBind();
conn.Close();
}
}
为什么图片不显示啊?
后台代码是这样的:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack )
{ SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["sql"]);
string cmd = "select * from img";
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd,conn );
DataSet ds = new DataSet();
da.Fill(ds);
DataList1.DataSource = ds.Tables[0].DefaultView;
DataList1.DataBind();
conn.Close();
}
}
为什么图片不显示啊?
解决方案 »
- asp.net如何打开文件窗口
- 点击重试才能刷新
- ASP.NET如何实现多条件的查询语句
- 求一个防止sql注入的客户端代码,谢谢
- (菜鸟问题)大家帮帮我啊!!! "找不到类型或命名空间名称"DBAccess"(是否缺少using指令或程序集引用?)"是怎么回事啊,搞了半天!!!!!!
- 求在Aspx文件中能正常运行的下接菜单
- 急!!!
- 如何安装treeview?
- 未能在设计试图中打开。在“<%..."值"...%>”块中,以不同方式将值括起来
- asp.net(c#)调visio的问题
- ASP.NET用JavaScript实现文件上传,请帮我看看问题出在哪里?
- 如何避免这种情况下界面刷新??(怒吼)
protected void DataListimagebind()
{
try
{
articleBean.BX_article_stateId = 1;
articleBean.BX_article_areaId = 0;
articleBean.BX_article_typeId = 4;
articleBean.BX_article_userId = 0;
articleBean.BX_articleIsRecommend = true;
articleBean.BX_articleIsTop = false;
articleDs = articleControl.BX_Function_SelectArticleIMAGE(articleBean, 2);
if (articleDs.Tables.Count > 0)
{
articleDs.Tables[0].Columns.Add("linkaddress");
articleDs.Tables[0].Columns.Add("title");
articleDs.Tables[0].Columns.Add("image");
if (articleDs.Tables[0].Rows.Count > 0)
{
foreach (DataRow row in articleDs.Tables[0].Rows)
{
row["linkaddress"] = ApplicationParas.getMainUrl() + "articlesWeb/articleDetails.aspx?id=" + row["BX_articleId"].ToString();
//row["linkaddress"] = "articlesWeb/articleDetails.aspx?id=" + row["BX_articleId"].ToString();
if (row["BX_articleTitle"].ToString().Length > 7)
row["title"] = row["BX_articleTitle"].ToString().Substring(0, 7);
else
row["title"] = row["BX_articleTitle"];
if (row["BX_articleTitleImgURL"].ToString().Length >= 4 && row["BX_articleTitleImgURL"].ToString().Trim().Substring(0, 4) == "http")
row["image"] = row["BX_articleTitleImgURL"];
else
{
if (row["BX_articleTitleImgURL"].ToString() == "" || row["BX_articleTitleImgURL"].ToString().IndexOf(".") < 0)
row["image"] = ApplicationParas.getMainUrl() + "bxmanage/images/default/default.jpg";
else
row["iamge"] = ApplicationParas.getMainUrl() + row["BX_articleTitleImgURL"];
}
}
}
DataListimage.DataSource = articleDs.Tables[0].DefaultView;
DataListimage.DataBind();
}
}
catch (Exception ex)
{
Response.Redirect(ApplicationParas.getMainUrl() + "/Error.aspx");
}
}
我写的你看下把
你的img_path是什么内容啊??
看看到底什么东西
在到<asp:Image ID="Image1" runat="server" Height="110px" Width="110px" ImageUrl='<%=VirtualPathUtility.ToAbsolute("~/")%>Admin/Img/<%#"DataBinder.Eval(Container.DataItem,"img_path")%>'/> 上面看看
然后我的图片路径就要到Img文件夹下来读取,格式怎么写啊?写了那么多都没有效果呢,大家帮我写个最后的啊!
高手你帮我解决这个问题啊,这个问题纠结了怎么久,还是解决不了,img_path就是上传存储图片的路径的,