Bind DetailsView field to Function instead of Property
Is it possible to display the result of a function instead of the value of a property in a DetailsView开发者_开发技巧 Field?
For example instead of:
<asp:Label ID="m_LabelPlantCode" runat="server" Text='<%# Bind("PlantCode") %>'></asp:Label>
maybe something like:
<asp:Label ID="m_LabelPlantCode" runat="server" Text='<%# Bind("PlantCode(true)") %>'></asp:Label>
You can do this:
Text='<%# ((YourObject) Container.DataItem).PlantCode(true) %>'
Yes it is possible to bind the result of a function to a field of DetailsView.
Instead of <%# Bind("PlantCode(true)") %>
you could use <%# SomeFunc(Bind("PlantCode") %>
and SomeFunc
in this case would a server side method accepting args of type PlantCode
.
Hope it helps!
精彩评论