R
rn5a
An ASPX page has a DataList which only displays the first name of the
users. When any of the first names is clicked, the DataList displays
the details of that user i.e. his full name, e-mail, address etc. This
is how I am doing it:
<script runat="server">
Sub Page_Load(.....)
'populate the data source with
'the data & bind it to the DataList
End Sub
Sub dl_ItemCommand(..........)
dl.SelectedIndex = ea.Item.ItemIndex
dl.DataBind()
End Sub
</script>
<form runat="server">
<asp
ataList ID="dl" OnItemCommand="dl_ItemCommand"
RepeatLayout="table" RepeatDirection="horizontal" runat="server">
<ItemTemplate>
<asp:LinkButton ID="lnkFName" CommandName="Select" runat="server"><%#
Container.DataItem("FirstName") %></asp:LinkButton> |
</ItemTemplate>
<SelectedItemTemplate>
Name: <%# Container.DataItem("FirstName") & " " &
Container.DataItem("LastName") %><br>
E-Mail;<%# Container.DataItem("EMail") %><br>
Address: <%# Container.DataItem("Address") %>
<%# Container.DataItem("City") %>
<%# Container.DataItem("State") %>
<%# Container.DataItem("Zip") %><br><br>
</SelectedItemTemplate>
</asp
ataList>
</form>
The above code shows the details of the user when the first name of a
user is clicked but I also want a LinkButton to accompany the details
of each user which when clicked should hide the details & display just
the first name of the user that was selected. There's no problem in
adding a LinkButton with the details which I did by adding a
LinkButton just before the </SelectedItemTemplate> line.
<asp:LinkButton ID="lnkClose" CommandArgument='<%#
Container.DataItem("FirstName") %>' Text="CLOSE" runat="server"/>
So when the first name of a user is clicked, it gets replaced by the
details of that user along with a "CLOSE" LinkButton. The problem is
when the "CLOSE" LinkButton (which is displayed along with the details
of the user) is clicked, how do I hide the details of the selected
user (plus the "CLOSE" LinkButton) & display only the user's first
name .
I can't use the <EditItemTemplate> in this case since the CommandName
of the LinkButton "lnkFName" has already been set to Select.
users. When any of the first names is clicked, the DataList displays
the details of that user i.e. his full name, e-mail, address etc. This
is how I am doing it:
<script runat="server">
Sub Page_Load(.....)
'populate the data source with
'the data & bind it to the DataList
End Sub
Sub dl_ItemCommand(..........)
dl.SelectedIndex = ea.Item.ItemIndex
dl.DataBind()
End Sub
</script>
<form runat="server">
<asp
RepeatLayout="table" RepeatDirection="horizontal" runat="server">
<ItemTemplate>
<asp:LinkButton ID="lnkFName" CommandName="Select" runat="server"><%#
Container.DataItem("FirstName") %></asp:LinkButton> |
</ItemTemplate>
<SelectedItemTemplate>
Name: <%# Container.DataItem("FirstName") & " " &
Container.DataItem("LastName") %><br>
E-Mail;<%# Container.DataItem("EMail") %><br>
Address: <%# Container.DataItem("Address") %>
<%# Container.DataItem("City") %>
<%# Container.DataItem("State") %>
<%# Container.DataItem("Zip") %><br><br>
</SelectedItemTemplate>
</asp
</form>
The above code shows the details of the user when the first name of a
user is clicked but I also want a LinkButton to accompany the details
of each user which when clicked should hide the details & display just
the first name of the user that was selected. There's no problem in
adding a LinkButton with the details which I did by adding a
LinkButton just before the </SelectedItemTemplate> line.
<asp:LinkButton ID="lnkClose" CommandArgument='<%#
Container.DataItem("FirstName") %>' Text="CLOSE" runat="server"/>
So when the first name of a user is clicked, it gets replaced by the
details of that user along with a "CLOSE" LinkButton. The problem is
when the "CLOSE" LinkButton (which is displayed along with the details
of the user) is clicked, how do I hide the details of the selected
user (plus the "CLOSE" LinkButton) & display only the user's first
name .
I can't use the <EditItemTemplate> in this case since the CommandName
of the LinkButton "lnkFName" has already been set to Select.