如何从转发器中检索图像 [英] how to retrive the image from repeater
本文介绍了如何从转发器中检索图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
图像已经在转发器中绑定。我希望转发器的图像路径。
image will already bind in the repeater.in that i want image path from repeater.
foreach (RepeaterItem item in Repeater1.Items)
{
Image im = (Image)item.FindControl("Image1");
Label l1 = (Label)item.FindControl("Label1");
Label l2 = (Label)item.FindControl("Label2");
con.Open();
string query = "insert into MyCart values('" + im.ToString()+ "','" + l1.Text + "','" + l2.Text + "')";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();
}
推荐答案
如果您尝试输入转换器,请确保在转发器中使用了ASP Image控件到图像如
Make sure that you have used an ASP Image control in the repeater if you are trying to type cast it to Image like
Image im = (Image)item.FindControl("Image1");
如果是html图像控件那么尝试以下
If it is a html image control then try following
HtmlControl im = (HtmlControl)item.FindControl("Image1");
希望,它有帮助:)
Hope, it helps :)
这篇关于如何从转发器中检索图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文