469,641 Members | 1,189 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,641 developers. It's quick & easy.

Enable/Disable Links

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
2 2954
well, you could determine which button was clicked and enable all but that
one..
-- assuming you give the control the same id as orderID..

foreach(Control ctrl in Page.Controls)
{
if(ctrl is LinkButton && ctrl.Id == Request.QueryString["orderID"])
{
ctrl.Enabled = false;
}
else
{
ctrl.Enabled = true;
}

}

Also make sure you are doing some security so that userID=14 cant see orders
that get passed as userID=15

"rn**@rediffmail.com" wrote:
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| </td>
</ItemTemplate>
<FooterTemplate>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>

Oct 17 '06 #2
aiKeith, how do I set the ID attribute values of the LinkButtons within
the Repeater the same as the OrderID dynamically? I tried this:

<td><asp:LinkButton ID="<%# Container.DataItem("OrderID") %>" Text="<%#
Container.ItemIndex + 1 %>" runat="server"/>&nbsp;|&nbsp;</td>

but this generates the following error:

The server tag is not well formed.

pointing to the above <asp:LinkButton ID=....../line. What's wrong
with the <asp:LinkButton....line?

This is how I am binding data to the Repeater:

<script runat="server">
Sub Page_Load(.....)
Dim sqlReader As SqlDataReader

sqlReader = 'calling a function that returns SqlDataReader

Repeater1.DataSource = sqlReader
Repeater1.DataBind()
End Sub
</script>

Please suggest a way out. I desperately need a solution.

aiKeith wrote:
well, you could determine which button was clicked and enable all but that
one..
-- assuming you give the control the same id as orderID..

foreach(Control ctrl in Page.Controls)
{
if(ctrl is LinkButton && ctrl.Id == Request.QueryString["orderID"])
{
ctrl.Enabled = false;
}
else
{
ctrl.Enabled = true;
}

}

Also make sure you are doing some security so that userID=14 cant see orders
that get passed as userID=15

"rn**@rediffmail.com" wrote:
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| </td>
</ItemTemplate>
<FooterTemplate>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>
Oct 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by BARBARA FLOYD | last post: by
reply views Thread by talal | last post: by
8 posts views Thread by rongchaua | last post: by
reply views Thread by rn5a | last post: by
56 posts views Thread by Deepan HTML | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.