用ImageButton显示图片
我在程序料下的Picture文件中放了a.jpg,然後在版面中建了一DataList控件,在项模板下加了一个ImageButton,数据库存了图片的地址。如数据库字段PhotoUrl为~\picture\chenji2.jpg。我把ImageButton.ImageURL性定数据库中的字段
如:
<asp:ImageButton ID= "Photoes " Width= "130 "Height= "100 "runat= "server " CommandName= "photo " ImageUrl= ' <%DataBinder.Eval(Container.DataItem, "PhotoUrl ") %> ' ImageAlign= "Bottom " />
~/Picture/a.jpg)。法正常示的片,我哪弄了?
如果把代码设定为固定的图片是可以的
如:
<asp:ImageButton ID= "Photoes " Width= "130 "Height= "100 "runat= "server " CommandName= "photo " ImageUrl= '~/Picture/a.jpg ' ImageAlign= "Bottom " />
可是我还是想动态的显示图片呀
请各位大哥指导
万 分感谢
在线等待
[解决办法]
应在CS代码中写
Photoes.ImageUrl =
[解决办法]
初始化了吗?你给PhotoUrl赋值了吗?
[解决办法]
主的是片路.
你把中的片路改成的格式:Picture/a.jpg
去掉~
[解决办法]
<asp:ImageButton ID= "Photoes " Width= "130 "Height= "100 "runat= "server " CommandName= "photo " ImageUrl= ' <%#DataBinder.Eval(Container.DataItem, "PhotoUrl ") %> ' ImageAlign= "Bottom " />