Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding a DropDownList in ListView InsertItemTemplate throwing an error
    primarykey
    data
    text
    <p>I've got a ListView which binds to a LinqDataSource and displays selected locations. The insert item Contains a dropdownlist that pulls from another LinqDataSource to give all the unselected locations.</p> <p>The problem is that I get the following error when loading the page:</p> <p>Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. </p> <p>I'm doing a very similar setup in another page of the website, and it isn't giving us this error so I'm pretty confused. I know I can work around this by not binding, manually finding the control and getting the value, but this should work and I don't understand why it isn't.</p> <p>Any thoughts?</p> <p>The better part of the source code is below.</p> <pre><code>&lt;asp:LinqDataSource ID="ldsLocations" runat="server" ContextTypeName="ClearviewInterface.ESLinqDataContext" EnableDelete="true" EnableInsert="true" OnInserting="ldsLocations_Inserting" OnDeleting="ldsLocations_Deleting" TableName="crmLocations" OrderBy="addr1" OnSelecting="ldsLocations_Selecting" /&gt; &lt;asp:LinqDataSource ID="ldsFreeLocations" runat="server" ContextTypeName="ClearviewInterface.ESLinqDataContext" OrderBy="addr1" TableName="v_CVLocations" OnSelecting="ldsFreeLocations_Selecting" /&gt; &lt;asp:ListView ID="lvLocations" DataSourceID="ldsLocations" DataKeyNames="ID" InsertItemPosition="LastItem" runat="server" &gt; &lt;InsertItemTemplate&gt; &lt;tr&gt; &lt;td colspan="6"&gt;&lt;hr /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;asp:DropDownList ID="ddlFreeLocations" DataSourceID="ldsFreeLocations" DataTextField="addr1" DataValueField="record" MarkFirstMatch="true" SelectedValue='&lt;%# Bind("record") %&gt;' runat="server" /&gt; &lt;/td&gt; &lt;td&gt;&lt;asp:ImageButton ID="btnAdd" CommandName="Insert" SkinID="Insert" runat="server" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/InsertItemTemplate&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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