FormView/ListView master/detail problem

Discussion in 'ASP .Net' started by Henri Fournier, Mar 6, 2009.

  1. I'm using a LinqDataSource with a FormView to display a single master
    record. In the FormView's ItemTemplate, I have a nested ListView to insert,
    edit, delete the Details record. However, The ListView doesn't display
    anything, so I can't add records. I can't figure out what I'm missing to
    make this work.

    Henri

    Note: I removed all the extra data fields for simplicity.

    <asp:LinqDataSource ID="LinqDataSource1" runat="server"
    ContextTypeName="MyDataContext" EnableDelete="True"
    EnableInsert="True" EnableUpdate="True"
    oninserted="LinqDataSource1_Inserted"
    oninserting="LinqDataSource1_Inserting"
    onselecting="LinqDataSource1_Selecting"
    TableName="Company" Where="ItemID == @ItemID">

    <WhereParameters>
    <asp:parameter Name="ItemID" Type="Int32" />
    </WhereParameters>

    </asp:LinqDataSource><asp:FormView ID="FormView1" runat="server"
    DataKeyNames="ItemID" DataSourceID="LinqDataSource1">
    <ItemTemplate>
    <table border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td>Name:</td>
    <td><asp:Label ID="NameLabel" runat="server" Text='<%#
    Eval("Name") %>' /></td>
    </tr>
    </table>
    <asp:panel ID="pnlContacts" runat="server" Visible="True">
    <hr />
    <h2>Contacts</h2>
    <asp:ListView ID="lvContacts" runat="server" DataSource='<%#
    Eval("Contacts") %>'>
    <LayoutTemplate>
    <div>
    <table id="itemPlaceholderContainer" border="0"
    cellpadding="0" cellspacing="0">
    <tr id="itemPlaceholder" runat="server" />
    </table>
    </div>
    </LayoutTemplate>
    <ItemTemplate>
    <tr id="tr1" runat="server">
    <td rowspan="5"><asp:Button ID="btnEdit"
    runat="server" CommandName="Edit" Text="Edit" /></td>
    <td>Name: <asp:Label ID="lblFirstName"
    runat="server" Text='<%# Eval("FirstName") %>' />&nbsp;
    <asp:Label ID="lblLastName" runat="server"
    Text='<%# Eval("LastName") %>' /></td>
    </tr>
    </ItemTemplate>
    <InsertItemTemplate>
    <tr id="tr1" runat="server">
    <td rowspan="5"><asp:Button ID="btnInsert"
    runat="server" CommandName="Insert" Text="Insert" />
    <asp:Button ID="btnCancel" runat="server"
    CommandName="Cancel" Text="Cancel" /></td>
    <td>Name: <asp:TextBox ID="txtFirstName"
    runat="server" Text='<%# Bind("FirstName") %>' />&nbsp;
    <asp:TextBox ID="txtLastName" runat="server"
    Text='<%# Bind("LastName") %>' /></td>
    </tr>
    </InsertItemTemplate>
    <EditItemTemplate>
    <tr id="tr1" runat="server">
    <td rowspan="5"><asp:Button ID="btnUpdate"
    runat="server" CommandName="Update" Text="Update" />
    <asp:Button ID="btnCancel" runat="server"
    CommandName="Cancel" Text="Cancel" /></td>
    <td>Name: <asp:TextBox ID="txtFirstName"
    runat="server" Text='<%# Bind("FirstName") %>' />&nbsp;
    <asp:TextBox ID="txtLastName" runat="server"
    Text='<%# Bind("LastName") %>' /></td>
    </tr>
    </EditItemTemplate>
    <EmptyDataTemplate>
    <tr id="trNoData" runat="server">
    <td colspan="3">No Team Members yet.</td>
    </tr>
    </EmptyDataTemplate>
    </asp:ListView>
    </asp:panel>
    </ItemTemplate>
    </asp:FormView>
    Henri Fournier, Mar 6, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. asmj
    Replies:
    0
    Views:
    499
  2. Aamir Ghanchi
    Replies:
    2
    Views:
    5,786
    Aamir Ghanchi
    Jan 18, 2008
  3. yixiang
    Replies:
    1
    Views:
    2,573
    Milosz Skalecki [MCAD]
    Jan 29, 2008
  4. Arun Kumar Menon

    Master Detail detail

    Arun Kumar Menon, Aug 6, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    196
    Arun Kumar Menon
    Aug 6, 2003
  5. Frederik Borg

    ASp.net data binding: Master-detail-detail

    Frederik Borg, Jun 9, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    354
    Frederik Borg
    Jun 9, 2006
Loading...

Share This Page