将图像插入网格视图(需要路径而不是名称) [英] Insert image into grid-view ( need the path not the name)
本文介绍了将图像插入网格视图(需要路径而不是名称)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好我有桌子(gridview)我使用功能更新上传图片我使用了
-Gridview Row_updating
-Gridview Row_command
但是在数据库的上传栏中我得到了文件的名称
((*我想要路径))
-Gridview Row_updating
hello i have table(gridview) i use the features update the upload image i used the
-Gridview Row_updating
-Gridview Row_command
but in the upload column in database i get the name of the file
((* I want the path))
-Gridview Row_updating
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow row = GridView1.Rows[e.RowIndex] as GridViewRow;
FileUpload FileUpload1 = (FileUpload)GridView1.Rows[e.RowIndex].FindControl("FileUpload1");
if (FileUpload1 != null && FileUpload1.HasFile)
{
FileUpload1.SaveAs(Server.MapPath("~/Cars/Car_Image/" + FileUpload1.FileName));
}
}
-Gridview Row_command
我的尝试:
-Gridview Row_command
What I have tried:
<pre>protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (GridView1.EditIndex == -1) return;
FileUpload fileUpLoad = GridView1.Rows[GridView1.EditIndex].FindControl("FileUpload1") as FileUpload;
string fileName = fileUpLoad.FileName;
TextBox txtImage = GridView1.Rows[GridView1.EditIndex].FindControl("TextBox14") as TextBox;
if (fileUpLoad != null && fileUpLoad.HasFile)
{
txtImage.Text = fileUpLoad.FileName;
}
else
{
txtImage.Text = txtImage.Text;
}
}
推荐答案
如果您的意思是客户端上图像的原始路径,那么您可以'出于安全原因,我们会这样做。
If you mean the original path of the image on the client then you can't get that for security reasons.
这篇关于将图像插入网格视图(需要路径而不是名称)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文