asp.net中imagebutton后台怎样通过读取相对路径显示图片
代码如下,从数据库读取储存的图片相对路径protectedvoidImageButton1_Click(objectsender,ImageClickEventArgse...
代码如下,从数据库读取储存的图片相对路径
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SqlConnection conn = new SqlConnection(s);
conn.Open();
string str = "select Image_Wpath from Image where Image_ID=1";
SqlCommand com = new SqlCommand(str, conn);
SqlDataReader reader = com.ExecuteReader();
if (reader.Read())
{
string Wapth = reader["Image_Wpath"].ToString();
Session["url"] = Wapth;
}
reader.Close();
conn.Close();
string url=Session["url"].ToString();
ImageButton1.ImageUrl=url;
}
在页面中图片显示不出来,是不是ImageButton1.ImageUrl=url写得不对,求大神解答,如何修改! 展开
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
SqlConnection conn = new SqlConnection(s);
conn.Open();
string str = "select Image_Wpath from Image where Image_ID=1";
SqlCommand com = new SqlCommand(str, conn);
SqlDataReader reader = com.ExecuteReader();
if (reader.Read())
{
string Wapth = reader["Image_Wpath"].ToString();
Session["url"] = Wapth;
}
reader.Close();
conn.Close();
string url=Session["url"].ToString();
ImageButton1.ImageUrl=url;
}
在页面中图片显示不出来,是不是ImageButton1.ImageUrl=url写得不对,求大神解答,如何修改! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询