Dynamic Data first steps and first issues :-)

I started working on a project with asp.net Dynamic Data and MVC.

We are using Linq2Sql, and I created 2 nested asp:Listview's to display Master/Detail data, grouped by Master.

 

With the following code

<ItemTemplate> 
      <tr> 
          <td> 
              <asp:DynamicControl ID="DynamicControl1" runat="server" DataField="EquipmentName" Mode="ReadOnly" /> 
          </td> 
          <td> 
              <asp:LinkButton runat="server" ID="ilnkDelete" Text="Remove" CommandName="DeleteEquipment" 
                  CommandArgument='<%# Eval("EquipmentID") %>' OnClientClick='return confirm("Are you sure you want to delete this item?");' /> 
          </td> 
      </tr> 
</ItemTemplate>

 

I get an error if I click on the Delete Link

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: The DynamicControl/DynamicField needs to exist inside a data control that is bound to a data source that supports Dynamic Data.

 

After struggling around with 2 LinqDatasources, UpdatePanels, Gridviews and all other possibilities, I found out:
If I change all the DynamicControl to Eval it works!

This code works

<ItemTemplate>     <tr>         <td>            <%# Eval("EquipmentName") %>         </td>         <td>             <asp:LinkButton runat="server" ID="ilnkDelete" Text="Remove" CommandName="DeleteEquipment"                 CommandArgument='<%# Eval("EquipmentID") %>' OnClientClick='return confirm("Are you sure you want to delete this item?");' />         </td>     </tr> </ItemTemplate>

No comments:

Post a Comment

Latest Posts

Popular Posts