从代码隐藏访问图像控制
编译器错误消息:CS0030:无法将类型“System.Web.UI.Control”转换为“System.Web.UI.WebControls.ImageField”
Line 107: protected void BookListView_DataBinding(object sender, EventArgs e)
Line 108: {
Line 109: ImageField img = (ImageField)BookListView.FindControlR("Image1");
Line 110: if (img.ImageUrl == "")
Line 111: img.ImageUrl = "Snoimage.gif";
控件已找到,但...
第 109 行发生错误
FindControlR 是查找control
该控件位于列表视图中
<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Pic_Address") %>' />
Compiler Error Message: CS0030: Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ImageField'
Line 107: protected void BookListView_DataBinding(object sender, EventArgs e)
Line 108: {
Line 109: ImageField img = (ImageField)BookListView.FindControlR("Image1");
Line 110: if (img.ImageUrl == "")
Line 111: img.ImageUrl = "Snoimage.gif";
the control is find but ...
error occured in line 109
FindControlR is an extension to find the control
the control is located in a listview
<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Pic_Address") %>' />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在尝试投射图像 控件到 ImageField控制。
尝试稍微修改您的代码:
You're trying to cast an Image control to an ImageField control.
Try modifying your code slightly: