Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to add a property to a Table Adapter that can be bound to?
    primarykey
    data
    text
    <p>I have a database table <code>TravelRequest</code> that contains, amongst other things, the fields <code>SignOffName</code> and <code>SignOffDate</code>. I have a table adapter <code>TravelRequestTable</code> based on this table. I have a DetailsView control which uses this via an ObjectDataSource. Should be all fairly standard stuff.</p> <p>What I want to do is add a property called <code>SignOffNameDate</code> to the table adapter that combines the two fields <em>and</em> 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.</p> <p>This is what I tried:</p> <pre><code>public partial class TravelRequestDS { public partial class TravelRequestRow { public string SignOffNameDate { get { return CombineNameDate(SignOffName, SignOffDate); } } } } </code></pre> <p>This property works fine when I access it programmatically, but when I try bind to it in my aspx page:</p> <pre><code>&lt;asp:DetailsView ID="DetailsView_TravelRequest" runat="server" AutoGenerateRows="False" DataKeyNames="TravelRequestID" DataSourceID="ObjectDataSource_TravelRequest"&gt; &lt;Fields&gt; &lt;asp:BoundField DataField="SignOffNameDate" HeaderText="Sign Off" /&gt; ... </code></pre> <p>I get an System.Web.HttpException exception, "A field or property with the name 'SignOffNameDate' was not found on the selected data source."</p> <p>Any ideas how I can do this? Is there an attribute I need to add to the property?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload