错误从服务器端获取gridview中的ImageUrl [英] error get ImageUrl in gridview from server side

查看:90
本文介绍了错误从服务器端获取gridview中的ImageUrl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好在gridview中有图片





hi have image in gridview


<ItemTemplate><asp:Image ID="Img_Pic" runat="server" ImageUrl='<%#Bind("Pic")%>' Width="100" Height="100" /> </ItemTemplate>





我将服务器端的数据绑定到gridview



and i bind data from server side to gridview

GridView1.DataSource = dt;
GridView1.DataBind();





事件GridView1_OnRowDeleting我可以在事件中访问id字段gridview

和delet行来自数据库

i想要从文件夹中删除文件的图像:



in event GridView1_OnRowDeleting i can access to id field gridview in event
and delet rows from databse
i want too get imageurl for delete file from folder:

int id = Convert.ToInt32(((Label)GridView1.Rows[e.RowIndex].FindControl("lbl_ID_LghtBx")).Text);
 Image a = ((Image) GridView1.Rows[e.RowIndex].FindControl("Img_Pic"));

FileInfo myfileinf = new FileInfo("~/img/LghtBx") + "/" + Pic.FileName);
 myfileinf.Delete();





但我在图片中得到错误a =((图片)GridView1.Rows [e .RowIndex] .FindControl(Img_Pic)):

错误5''图像''是''System.Drawing.Image''和''System.Web.UI之间的模糊引用。 WebControls.Image''



but i get error in Image a = ((Image) GridView1.Rows[e.RowIndex].FindControl("Img_Pic")):
Error 5 ''Image'' is an ambiguous reference between ''System.Drawing.Image'' and ''System.Web.UI.WebControls.Image''

推荐答案

错误告诉你究竟出了什么问题,这是告诉应用程序使用什么Image类所以使用下面的代码并检查你的问题将解决。

The error tells you exactly what is wrong, which is to tell the application what "Image" class to use so use following code and check your problem will resolve.
System.Drawing.Image a = ((System.Drawing.Image) GridView1.Rows[e.RowIndex].FindControl("Img_Pic"));


错误5''图像'是''System.Drawing.Image''和''System.Web.UI.WebControls.Image''

之间的模糊引用在您使用的Image控件上,请相应地更新代码行。很可能你正在使用Image web控件,如果是这样,代码应该是:

Error 5 ''Image'' is an ambiguous reference between ''System.Drawing.Image'' and ''System.Web.UI.WebControls.Image''
Based on which Image control you have used, please update the line of code accordingly. Most probably you are using Image web control and if so, the code should be:
Image a = ((System.Web.UI.WebControls.Image) GridView1.Rows[e.RowIndex].FindControl("Img_Pic")):





上面的错误只是告诉编译器无法理解你在说什么图像。



Error above just tells that compiler is unable to understand which Image you are talking of.


这篇关于错误从服务器端获取gridview中的ImageUrl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆