如图所示,如何通过加减按钮改变相应的item的数量+1或-1,相应的控件位置已由红字标识
如何通过+、-的linkbutton来改变当前相应numberTB的数值+1或-1,当为1时就不能再减了,具体代码如下
<asp:ListView ID="medicineLV" runat="server"
GroupItemCount="4" >
<EmptyItemTemplate>
<td runat="server" />
</EmptyItemTemplate>
<ItemTemplate>
<td runat="server" style="">
<table style="font-size: medium">
<tr>
<td colspan="2">
<a href='Drug_Info.aspx?medicine_id=<%# Eval("medicine_id") %>'>
<asp:Image ID="medicineImage" runat="server" Height="150px"
ImageUrl='<%# "~/Images/"+Eval("medicine_image_path") %>' Width="154px" />
</a>
</td>
</tr>
<tr>
<td style="width: 9%">
药名:</td>
<td>
<a href='Drug_Info.aspx?medicine_id=<%# Eval("medicine_id") %>'>
<asp:Label ID="nameLb" runat="server" Text='<%# Eval("medicine_name") %>'></asp:Label>
</a>
</td>
</tr>
<tr>
<td style="width: 9%">
药价:</td>
<td>
<asp:Label ID="priceLb" runat="server" Text='<%# Eval("medicine_price")+"元" %>'></asp:Label>
</td>
</tr>
<tr>
<td style="width: 9%">
数量:</td>
<td>
<asp:LinkButton ID="cutLB" runat="server">-</asp:LinkButton>
<asp:TextBox ID="numberTB" runat="server">1</asp:TextBox>
<asp:LinkButton ID="addLB" runat="server">+</asp:LinkButton>
</td>
</tr>
<tr>
<td colspan="2" style="width: 45%">
<asp:Button ID="buyBt" runat="server" CausesValidation="False"
OnClick="buyBt_Click" Text='<%# "立刻购买" %>' />
<asp:Button ID="gwcBt" runat="server" CausesValidation="False"
OnClick="gwcBt_Click" Text='<%# "加入购物车" %>' />
</td>
</tr>
</table>
</td>
</ItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
对不起没有找到该类药品</td>
</tr>
</table>
</EmptyDataTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="groupPlaceholderContainer" runat="server" border="0" style="">
<tr ID="groupPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
<asp:DataPager ID="medicineDP" runat="server" PageSize="8">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr ID="itemPlaceholderContainer" runat="server">
<td ID="itemPlaceholder" runat="server">
</td>
</tr>
</GroupTemplate>
</asp:ListView>