I have a database table TravelRequest
that contains, amongst other things, the fields SignOffName
and SignOffDate
. I have a table adapter TravelRequestTable
based on this table. I have a DetailsView control which uses this via an ObjectDataSource. Should be all fairly standard stuff.
What I want to do is add a property called SignOffNameDate
to the table adapter that combines the two fields and be able to bind to it in the DetailsView control. I want to do it programmatically rather than adding another column in the SQL because dealing with null values is tricky and depends on some other business rules.
This is what I tried:
public partial class TravelRequestDS
{
public partial class TravelRequestRow
{
public string SignOffNameDate
{
get { return CombineNameDate(SignOffName, SignOffDate); }
}
}
}
This property works fine when I access it programmatically, but when I try bind to it in my aspx page:
<asp:DetailsView ID="DetailsView_TravelRequest" runat="server" AutoGenerateRows="False"
DataKeyNames="TravelRequestID" DataSourceID="ObjectDataSource_TravelRequest">
<Fields>
<asp:BoundField DataField="SignOffNameDate"
HeaderText="Sign Off" />
...
I get an System.Web.HttpException exception, "A field or property with the name 'SignOffNameDate' was not found on the selected data source."
Any ideas how I can do this? Is there an attribute I need to add to the property?