Search code examples
asp.netdata-bindingdetailsview

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>

Solution

  • You can do this:

    Text='<%# ((YourObject) Container.DataItem).PlantCode(true) %>'