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.
The problem is that I get the following error when loading the page:
Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.
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.
Any thoughts?
The better part of the source code is below.
<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" />
<asp:LinqDataSource ID="ldsFreeLocations" runat="server"
ContextTypeName="ClearviewInterface.ESLinqDataContext" OrderBy="addr1"
TableName="v_CVLocations" OnSelecting="ldsFreeLocations_Selecting" />
<asp:ListView ID="lvLocations" DataSourceID="ldsLocations" DataKeyNames="ID" InsertItemPosition="LastItem" runat="server" >
<InsertItemTemplate>
<tr>
<td colspan="6"><hr /></td>
</tr>
<tr>
<td colspan="2">
<asp:DropDownList ID="ddlFreeLocations" DataSourceID="ldsFreeLocations" DataTextField="addr1"
DataValueField="record" MarkFirstMatch="true" SelectedValue='<%# Bind("record") %>'
runat="server" />
</td>
<td><asp:ImageButton ID="btnAdd" CommandName="Insert" SkinID="Insert" runat="server" /></td>
</tr>
</InsertItemTemplate>