在gridview中显示图像。 [英] Show image in gridview.
本文介绍了在gridview中显示图像。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hii我已经使用下面的代码上传图像了它的工作。图像路径在数据库中存在并且图像也存储在文件夹中bt图像没有在gridview中显示。我该怎么办...使用此代码plzz编辑或修改代码在gridview中显示图像..
Hii i have been uploaded image using below code its working.Image path is gooing in database and image also storing in folder bt image is not displaying in gridview.How can i do.. using this code plzz edit or modify code for show image in gridview..
SqlConnection con = new SqlConnection("Data Source=DEEPAK-PC\\SQLEXPRESS;Initial Catalog=Imageup;User ID=sa;Password=sasa");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
String str = FileUpload1.FileName;
//FileUpload1.PostedFile.SaveAs(Server.MapPath(",") + "~//uploadedimages//" + str);
string FileName= Path.GetFileName(FileUpload1.FileName);
FileUpload1.SaveAs(Server.MapPath("~/uploadedimages/")+ FileName);
string path = "~//Uploads//"+str.ToString();
con.Open();
SqlCommand cmd = new SqlCommand("insert into FileUploads1 values('" + TextBox1.Text + "','" + path + "')", con);
cmd.ExecuteNonQuery();
con.Close();
Label1.Text = "Image upload Successfully";
}
else
{
Label1.Text = "Plz select ur image and upload";
}
SqlDataAdapter da = new SqlDataAdapter("select * from FileUploads1", con);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
DataBind();
}
推荐答案
使用图像处理程序进行显示gridview中的图片。
参考: http://stackoverflow.com/questions/19132451/how-to-display-binary-images-into-a-gridview-in-asp-net-using-c [ ^ ]
希望这会有所帮助。
Use image handler for displaying image in gridview.
Refer :http://stackoverflow.com/questions/19132451/how-to-display-binary-images-into-a-gridview-in-asp-net-using-c[^]
Hope this will help.
hi ...
查看此链接,可能对您有所帮助。
如何在datalist / gridview中绑定图像 [ ^ ]
Tha nk u。
hi...
See this link,may its help ful to u.
How to bind images in datalist/gridview[^]
Thank u.
参考
http://www.aspdotnet-suresh.com/2011/03/how-to-save-images-into-folder-and.html [ ^ ]
此外,在保存文件和插入数据库路径时检查路径是否相同。
Refer
http://www.aspdotnet-suresh.com/2011/03/how-to-save-images-into-folder-and.html[^]
Also , check the paths are same while saving the file and inserted path to DB.
FileUpload1.SaveAs(Server.MapPath("~/uploadedimages/")+ FileName);
和
and the
"insert into FileUploads1 values('" + TextBox1.Text + "','" + path + "'
应该是一样的。
希望这有帮助......
should be same .
Hope this helps...
这篇关于在gridview中显示图像。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文