Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET 4.0 using DynamicControl within embedded Listview
    text
    copied!<p>I have an embedded listview (within another listview), and both listviews are succesfully allowing CRUD operations.</p> <p>the asp for the embedded listview looks like this:</p> <pre><code>&lt;asp:ObjectDataSource ID="objConcentrations" runat="server" TypeName="PICUdrugs.BLL.infusionBL" DataObjectTypeName="PICUdrugs.DAL.infusionConcentration" InsertMethod="insertConcentration" SelectMethod="getConcentrations" deleteMethod="deleteConcentration" UpdateMethod="updateConcentration" OldValuesParameterFormatString="orig{0}" ConflictDetection="CompareAllValues" OnUpdated="objConcentrations_CRUD" OnInserted="objConcentrations_CRUD"&gt; &lt;SelectParameters&gt; &lt;asp:Parameter Name="infDilutionID" Type="Int32"/&gt; &lt;/SelectParameters&gt; &lt;/asp:ObjectDataSource&gt; &lt;asp:ListView ID="infusionConcListView" runat="server" DataSourceID="objConcentrations" ItemPlaceholderID="itemPlaceHolder1" InsertItemPosition="LastItem" DataKeyNames="infusionConcentrationID" OnDataBound="concentrationLV_allDataBound" EnableViewState="False"&gt; </code></pre> <p>with the onItemDataBound event of the outer listview setting the default value for the select parameter on the embedded objectDataSource as so:</p> <pre><code>protected void infDilutnLV_itemDataBound(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { ObjectDataSource infConcentrations = e.Item.FindControl("objConcentrations") as ObjectDataSource; ListViewDataItem dataItem = (ListViewDataItem)e.Item; if (infConcentrations != null) { infusionDilution infDil = (infusionDilution)dataItem.DataItem; Parameter parameter = infConcentrations.SelectParameters[0]; parameter.DefaultValue = infDil.infusionDilutionID.ToString(); } } } </code></pre> <p>The objectDataSource then uses an entity framework in the data access layer. I have set up dataAnnotations for the entity classes as so:</p> <pre><code>namespace PICUdrugs.DAL { [MetadataType(typeof(infusionDilutionMetaData))] public partial class infusionDilution { } public class infusionDilutionMetaData { [Range(0, 3000, ErrorMessage = "volume must be between 0 and 3000 ml")] public int? finalVol { get; set; } } [MetadataType(typeof(infusionConcentrationMetaData))] public partial class infusionConcentration { } public class infusionConcentrationMetaData { [Range(0.001, 1000, ErrorMessage = "concentration must be between 0.001 and 1000 units/ml")] public double Concentration { get; set; } } } </code></pre> <p>While the dynamicControls are working perfectly on the outer (non-nested) listview, when I change any controls to dynamic controls on the inner (nested) listview, I get the error: </p> <pre><code>Could not determine a MetaTable. A MetaTable could not be determined for the data source 'objConcentrations' and one could not be inferred from the request URL. Make sure that the table is mapped to the dats source, or that the data source is configured with a valid context type and table name, or that the request is part of a registered DynamicDataRoute. </code></pre> <p>i am afraid I am very much an amateur programmer, and I am unsure if it is even possible to use dynamicFields in a nested listview. Are there any workarounds, or is there an error in my code I am missing? Thank you very much for any help.</p>
 

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