By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,680 Members | 1,890 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,680 IT Pros & Developers. It's quick & easy.

Enable/Disable Links

P: n/a
In a shopping cart app, assume that a user has placed 4 orders (each
order has a corresponding OrderID which will be unique). When he comes
to MyCart.aspx, by default, the details of his last order he had placed
will be displayed in a DataList. Also assume that the OrderID of the
last order is 13.

The details of the earlier orders placed by a particular user (when the
user places more than 1 order) can be viewed by clicking links. The no.
of links displayed will depend upon how many orders a particular user
has placed i.e. the no. of links displayed will be equal to the total
no. of orders placed by a particular user minus one. I am displaying
these links in a Repeater control.

As per the assumption that a user has placed 4 orders, to view the
details of the previous 3 orders (the details of the last order is
currently displayed to the user), 3 links will be provided to the user
immediately after the DataList. Clicking any of the links will bring
the user back to MyCart.aspx. The URL of the links will have
querystrings, UserID & OrderID, appended at the end of the URL using
which the ASPX page will retrieve records from a DB table. The text of
the links wil be just numbers starting from 1. The links will be sorted
in the ascending order of the OrderID. So in this case, the user will
see 1, 2 & 3 as the links. So for e.g. if the previous 3 OrderIDs of
UserID=15 are 4, 7 & 9, the URL of the 3 links will be

MyCart.aspx?UserID=15&OrderID=4
MyCart.aspx?UserID=15&OrderID=7
MyCart.aspx?UserID=15&OrderID=9

respectively. Clicking link '1' will display the details of OrderID=4.
Similarly, clicking link '2' & link '3' will display the details of
OrderID=7 & OrderID=9 respectively.

Suppose the user clicks link '1'. He is taken to
MyCart.aspx?UserID=15&OrderID=4 which will display the details of
OrderID=4. Under such circumstances, I want that link '1' should no
longer remain a link; it should be just plain text. Next if the user
clicks link '2', the details of the order whose OrderID=7 will be
displayed & link '2' should no longer remain a link but link '1' should
become a link (so that the user can view the details of the order whose
OrderID=4 again, if he wants to). Similarly, if the user clicks link
'3', the details of the order whose OrderID=9 will be displayed & link
'3' should no longer remain a link but link '2' should become a link
(so that the user can view the details of the order whose OrderID=7
again, if he wants to) so on & so forth.

This is where I am getting stuck. How do I enable/disable the links
depending upon which link the user has clicked? Can someone suggest me
how do I accomplish this? I don't have any problems in displaying the
order details in the DataList depending upon which link the user clicks
or in displaying the links in the Repeater. My problem lies in
enabling/disabling the links.

Note that I am retrieving the DB records using a SqlDataReader,
assigning the DataSource property of the Repeater to the SqlDataReader
& finally binding the data to the Repeater using DataBind. The Repeater
control looks like this:

<asp:Repeater ID="rptrLinks" runat="server">
<HeaderTemplate>
<table>
<tr>
</HeaderTemplate>
<ItemTemplate>
<td><a href='MyCart.aspx?UserID=<%= Request.QueryString("UserID")
%>&OrderID=<%# Container.DataItem("OrderID") %>'><%#
Container.ItemIndex + 1 %></a>&nbsp;|&nbsp;</td>
</ItemTemplate>
<FooterTemplate>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>

Oct 17 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.