<asp:TemplateColumn HeaderText="图标">
<ItemTemplate>
<asp:Label ID="iconlink" runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.gmiconlink")%>'/>
<asp:Image ID="iconimg" runat="server" src=""/>
</ItemTemplate>
</asp:TemplateColum>想要实现的功能是 在label 的后面显示出对应的图标。我最初是想在 itemdatabound 中指定 iconimg的 imageurl值,但是在 datagrid中并没有显示出对应的图标,后来又在 itemcreated 中指定它的值,也是不行,最后干脆在模版列中去掉了iconimg控件,而在 itemcreated 中动态添加了一个 image 控件,再 指定imageurl值,但是仍然不行,而添加的其他控件,如,textbox,label则没有问题,。我想可能是image控件有什么特殊性,还请大家指点
<ItemTemplate>
<asp:Label ID="iconlink" runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.gmiconlink")%>'/>
<asp:Image ID="iconimg" runat="server" src=""/>
</ItemTemplate>
</asp:TemplateColum>想要实现的功能是 在label 的后面显示出对应的图标。我最初是想在 itemdatabound 中指定 iconimg的 imageurl值,但是在 datagrid中并没有显示出对应的图标,后来又在 itemcreated 中指定它的值,也是不行,最后干脆在模版列中去掉了iconimg控件,而在 itemcreated 中动态添加了一个 image 控件,再 指定imageurl值,但是仍然不行,而添加的其他控件,如,textbox,label则没有问题,。我想可能是image控件有什么特殊性,还请大家指点
你给
<asp:Image ID="iconimg" runat="server" src=""/>
src附值的语句肯定有问题,
你可以执行后打开html源码看看后面的<img 标记是否正确.//可以先把src写死试试.
((image)e.item.findcontrol("iconimg")).ImageUrl="~/images/bar_00.jpg";就是那个url写错了,因该是"../images/bar_00.jpg";我把前面的那个 写成了 "~"