我使用来自 asp.net 的转发器控件进行数据绑定。在设计中,我使用 div 和 span 来表示数据。我的表有 4 个字段,我想根据字段值在每个范围内显示图像。图像存储在我的项目路径本身中。
这个怎么做?
Use this
<asp:Repeater ID="RepeaterImages" runat="server">
<ItemTemplate>
<img src='<%#GetImage(Databinder.Eval(Container.DataItem, "ImageID"))%>' alt="" width="" height="" />
</ItemTemplate>
</asp:Repeater>
现在我们需要创建一个函数来使用该 ID 检索图像。
public string GetImage(object ImadeID)
{
if(ImageID!=null)
{
//do something with the ImageID to return the image path as string
}
else
{
return "";
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)