Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > FormView/ListView master/detail problem

Reply
Thread Tools

FormView/ListView master/detail problem

 
 
Henri Fournier
Guest
Posts: n/a
 
      03-06-2009
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>
<asparameter 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>
<aspanel 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>
</aspanel>
</ItemTemplate>
</asp:FormView>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments