B
Brian Gaze
I have created a ListView control and have bound this to a datasource.
Within the ItemTemplate of the ListView I have added another ListViewControl
which is databound in the code behind. The idea is that when clicking on the
"Show details" button the ListView for the appropriate row binds in the
codebehind and displays the detail data for the selected row. I did
something similar with a gridview control previously, but want to be able to
fully control the HTML produced now so don't want to go down that route.
The problem I am having is that the master ListView renders with the correct
data, but the embedded details ListView does not display at all. If I pull
the details ListView out of the master ListView and create seperately it
does render correctly. Is the problem being caused because the master
ListView is rendering before the details ListView is generated? Any help
appreciated.
Regards
Brian
Here's the code......
I'm trying to bind the details ListView in the SelectedIndexChanged event
of the master ListView, with something like this in the codebehind:
ListView tmp = new ListView();
tmp = (ListView)this.ListView1.Items[rowcount].FindControl("lvDetails");
tmp.DataSourceID = "ods1";
tmp.DataBind();
The declarative code is...
<ItemTemplate>
<tr>
<td>
<asp:LinkButton ID="LinkButton1" runat="server"
CausesValidation="False" CommandName="Select"
Text="Show details"
OnClick="LinkButton1_Click"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Hide details"></asp:LinkButton>
<asp:Label ID="Label10" runat="server" Text='<%#
Eval("[Field1]") + "kmh" %>'></asp:Label>
</td>
<td>
<asp:Label ID="Label9" runat="server" Text='<%#
Eval("Field2") + "mB"%>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<asp:ListView ID="lvDetails" runat="server"
EnableViewState="false">
<LayoutTemplate>
<ul>
<asplaceHolder ID="itemPlaceholder"
runat="server"></asplaceHolder>
</ul>
</LayoutTemplate>
<ItemTemplate>
<li>
<%# Eval("[Wind speed]")%>
<%# Eval("[Temperature]")%>
</li>
</ItemTemplate>
</asp:ListView>
</td>
</tr>
</ItemTemplate>
Within the ItemTemplate of the ListView I have added another ListViewControl
which is databound in the code behind. The idea is that when clicking on the
"Show details" button the ListView for the appropriate row binds in the
codebehind and displays the detail data for the selected row. I did
something similar with a gridview control previously, but want to be able to
fully control the HTML produced now so don't want to go down that route.
The problem I am having is that the master ListView renders with the correct
data, but the embedded details ListView does not display at all. If I pull
the details ListView out of the master ListView and create seperately it
does render correctly. Is the problem being caused because the master
ListView is rendering before the details ListView is generated? Any help
appreciated.
Regards
Brian
Here's the code......
I'm trying to bind the details ListView in the SelectedIndexChanged event
of the master ListView, with something like this in the codebehind:
ListView tmp = new ListView();
tmp = (ListView)this.ListView1.Items[rowcount].FindControl("lvDetails");
tmp.DataSourceID = "ods1";
tmp.DataBind();
The declarative code is...
<ItemTemplate>
<tr>
<td>
<asp:LinkButton ID="LinkButton1" runat="server"
CausesValidation="False" CommandName="Select"
Text="Show details"
OnClick="LinkButton1_Click"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Hide details"></asp:LinkButton>
<asp:Label ID="Label10" runat="server" Text='<%#
Eval("[Field1]") + "kmh" %>'></asp:Label>
</td>
<td>
<asp:Label ID="Label9" runat="server" Text='<%#
Eval("Field2") + "mB"%>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<asp:ListView ID="lvDetails" runat="server"
EnableViewState="false">
<LayoutTemplate>
<ul>
<asplaceHolder ID="itemPlaceholder"
runat="server"></asplaceHolder>
</ul>
</LayoutTemplate>
<ItemTemplate>
<li>
<%# Eval("[Wind speed]")%>
<%# Eval("[Temperature]")%>
</li>
</ItemTemplate>
</asp:ListView>
</td>
</tr>
</ItemTemplate>