title: How to code on "add to cart" button
body: <p>I am using list view, please tell me how to selct the particular item from listview template. In listview template I am using a button named "add to cart". And how to add the product to shopping cart page.</p>
  
  <pre><code>    &lt;asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" 
      GroupItemCount="5"&gt;
      &lt;AlternatingItemTemplate&gt;
          &lt;td runat="server" style="background-color:#FFF8DC;"&gt;
              &lt;asp:Image ID="Image2" runat="server" Height="101px" 
                  ImageUrl='&lt;%# Eval("img") %&gt;' Width="100px" /&gt;
              &lt;br /&gt;
              Title:
              &lt;asp:Label ID="titleLabel" runat="server" Text='&lt;%# Eval("title") %&gt;' /&gt;
              &lt;br /&gt;author:
              &lt;asp:Label ID="authorLabel" runat="server" Text='&lt;%# Eval("author") %&gt;' /&gt;
              &lt;br /&gt;publisher:
              &lt;asp:Label ID="publisherLabel" runat="server" Text='&lt;%# Eval("publisher") %&gt;' /&gt;
              &lt;br /&gt;price:
              &lt;asp:Label ID="priceLabel" runat="server" Text='&lt;%# Eval("price") %&gt;' /&gt;
              &lt;br /&gt;
              &lt;asp:Button ID="Button4" runat="server" Text="Add to Cart" 
                  OnClick="Button4_Click" PostBackUrl="~/ShoppingCart.aspx" /&gt;
              &lt;br /&gt;
          &lt;/td&gt;
      &lt;/AlternatingItemTemplate&gt;
      &lt;EditItemTemplate&gt;
          &lt;td runat="server" style="background-color:#FFF8DC;"&gt;
              &lt;asp:Image ID="Image2" runat="server" Height="101px" 
                  ImageUrl='&lt;%# Eval("img") %&gt;' Width="100px" /&gt;
              &lt;br /&gt;
              Title:
              &lt;asp:Label ID="titleLabel" runat="server" Text='&lt;%# Eval("title") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;br /&gt;author:
              &lt;asp:Label ID="authorLabel" runat="server" Text='&lt;%# Eval("author") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;br /&gt;publisher:
              &lt;asp:Label ID="publisherLabel" runat="server" Text='&lt;%# Eval("publisher") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;br /&gt;price:
              &lt;asp:Label ID="priceLabel" runat="server" Text='&lt;%# Eval("price") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;br /&gt;
              &lt;asp:Button ID="Button4" runat="server" 
                  Text="Add to Cart" OnClick="Button4_Click" 
                  OnClientClick='&lt;%# Eval("title", "{0}") %&gt;' PostBackUrl="~/ShoppingCart.aspx" /&gt;
              &lt;br /&gt;
          &lt;/td&gt;
      &lt;/EditItemTemplate&gt;
      &lt;EmptyDataTemplate&gt;
          &lt;table runat="server" 
              style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;"&gt;
              &lt;tr&gt;
                  &lt;td&gt;
                      No data was returned.&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/EmptyDataTemplate&gt;
      &lt;EmptyItemTemplate&gt;
  &lt;td runat="server" /&gt;
      &lt;/EmptyItemTemplate&gt;
      &lt;GroupTemplate&gt;
          &lt;tr ID="itemPlaceholderContainer" runat="server"&gt;
              &lt;td ID="itemPlaceholder" runat="server"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/GroupTemplate&gt;
      &lt;InsertItemTemplate&gt;
          &lt;td runat="server" style=""&gt;
              title:
              &lt;asp:TextBox ID="titleTextBox" runat="server" Text='&lt;%# Bind("title") %&gt;' /&gt;
              &lt;br /&gt;author:
              &lt;asp:TextBox ID="authorTextBox" runat="server" Text='&lt;%# Bind("author") %&gt;' /&gt;
              &lt;br /&gt;publisher:
              &lt;asp:TextBox ID="publisherTextBox" runat="server" 
                  Text='&lt;%# Bind("publisher") %&gt;' /&gt;
              &lt;br /&gt;price:
              &lt;asp:TextBox ID="priceTextBox" runat="server" Text='&lt;%# Bind("price") %&gt;' /&gt;
              &lt;br /&gt;img:
              &lt;asp:TextBox ID="imgTextBox" runat="server" Text='&lt;%# Bind("img") %&gt;' /&gt;
              &lt;br /&gt;
              &lt;asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                  Text="Insert" /&gt;
              &lt;br /&gt;
              &lt;asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                  Text="Clear" /&gt;
              &lt;br /&gt;
          &lt;/td&gt;
      &lt;/InsertItemTemplate&gt;
      &lt;ItemTemplate&gt;
          &lt;td runat="server" style="background-color:#DCDCDC;color: #000000;"&gt;
              &lt;asp:Image ID="Image1" runat="server" Height="100px" 
                  ImageUrl='&lt;%# Eval("img") %&gt;' Width="101px" /&gt;
              &lt;br /&gt;
              Title:
              &lt;asp:Label ID="titleLabel" runat="server" Text='&lt;%# Eval("title") %&gt;' /&gt;
              &lt;br /&gt;Author:
              &lt;asp:Label ID="authorLabel" runat="server" Text='&lt;%# Eval("author") %&gt;' /&gt;
              &lt;br /&gt;Publisher:
              &lt;asp:Label ID="publisherLabel" runat="server" Text='&lt;%# Eval("publisher") %&gt;' /&gt;
              &lt;br /&gt;Price:
              &lt;asp:Label ID="priceLabel" runat="server" Text='&lt;%# Eval("price") %&gt;' /&gt;
              &lt;br /&gt;
              &lt;asp:Button ID="Button3" runat="server" Text="Add to Cart" 
                  OnClientClick='&lt;%# Eval("title", "{0}") %&gt;' /&gt;
              &lt;br /&gt;
          &lt;/td&gt;
      &lt;/ItemTemplate&gt;
      &lt;LayoutTemplate&gt;
          &lt;table runat="server"&gt;
              &lt;tr runat="server"&gt;
                  &lt;td runat="server"&gt;
                      &lt;table ID="groupPlaceholderContainer" runat="server" border="1" 
                          style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;"&gt;
                          &lt;tr ID="groupPlaceholder" runat="server"&gt;
                          &lt;/tr&gt;
                      &lt;/table&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr runat="server"&gt;
                  &lt;td runat="server" 
                      style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;"&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/LayoutTemplate&gt;
      &lt;SelectedItemTemplate&gt;
          &lt;td runat="server" 
              style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;"&gt;
              title:
              &lt;asp:Label ID="titleLabel" runat="server" Text='&lt;%# Eval("title") %&gt;' /&gt;
              &lt;br /&gt;author:
              &lt;asp:Label ID="authorLabel" runat="server" Text='&lt;%# Eval("author") %&gt;' /&gt;
              &lt;br /&gt;publisher:
              &lt;asp:Label ID="publisherLabel" runat="server" Text='&lt;%# Eval("publisher") %&gt;' /&gt;
              &lt;br /&gt;price:
              &lt;asp:Label ID="priceLabel" runat="server" Text='&lt;%# Eval("price") %&gt;' /&gt;
              &lt;br /&gt;img:
              &lt;asp:Label ID="imgLabel" runat="server" Text='&lt;%# Eval("img") %&gt;' /&gt;
              &lt;br /&gt;
          &lt;/td&gt;
      &lt;/SelectedItemTemplate&gt;
  
  &lt;/asp:ListView&gt;
  </code></pre>