DataList Close SelectedItem

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:DataList 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> | &nbsp;
</ItemTemplate>
<SelectedItemTemplate>
Name: <%# Container.DataItem("FirstName") & " " &
Container.DataItem("LastName") %><br>
E-Mail;<%# Container.DataItem("EMail") %><br>
Address: <%# Container.DataItem("Address") %>&nbsp;
<%# Container.DataItem("City") %>&nbsp;
<%# Container.DataItem("State") %>&nbsp;
<%# Container.DataItem("Zip") %><br><br>
</SelectedItemTemplate>
</asp:DataList>
</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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top