Let's say I have a DataGrid that looks something like this:
<asp:DataGrid ID="SomeDataGrid" runat="server"> <Columns> <asp:BoundColumn HeaderText="A Header" SortExpression="Sort" DataField="Data"></asp:BoundColumn> </Columns> </asp:DataGrid>
In this grid, I set the data source to some collection that contains the public property "Data" and makes databind() . Everyone works as expected.
Now let me say that I want to set the DataField attribute of a column to an open member or property or some other thing that I calculated. What is the easiest way to do this without creating intermediate objects or adding public properties to objects in the collection?
So what I want to do is something like:
<asp:BoundColumn HeaderText="A Header" SortExpression="Sort" DataField="someMethod()"></asp:BoundColumn>
source share