ASP.NET
  Home arrow ASP.NET arrow Page 4 - Making Use of the Repeater Web Server Cont...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Making Use of the Repeater Web Server Control
By: Justin Cook
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 14
    2004-06-28

    Table of Contents:
  • Making Use of the Repeater Web Server Control
  • Get the Data
  • Can You Repeat That Please?
  • Ooooh, Bubbles!
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Making Use of the Repeater Web Server Control - Ooooh, Bubbles!


    (Page 4 of 5 )

    Suppose you've decided that along with your nicely styled repetition of your inventory, it would be somewhat beneficial to your business for people to actually be able to purchase one or more of the items. A nice way to do that is stick a little button unambiguously labeled 'buy'. When you click 'buy', you want a subroutine that takes the ID of the item you want to buy, and takes you to the next step of credit card processing and such.

    I won't bother with the next step here, but I will show you how to embed a button control in the Repeater, and how to configure the button (child) to make the Repeater (parent) aware of its events. This is called bubbling. Think of bubbles starting at the bottom of a boiling pot, and rising to the surface to pop. That's essentially what's happening; the events/bubbles start at the bottom - the child - and rise to the top – the parent – to be handled.

    To do this, first we add the code to the container, the Repeater, to capture the events. Our repeater will now look like this:

    <asp:Repeater id="prodRepeater" runat="server" onItemCommand="getItem">

    Then, we add the child control, the button to the item template, and the alternating item template if you are using one. It would look like this:

    <asp:button runat="server" text="buy" CommandArgument='<%# Container.DataItem("id") %>' />

    We hide the id of the item in the CommandArgument member of the button, which we will pick up later. Once a user clicks 'buy', this raises an event, which is bubbled up to the repeater, which will hand it off to the following getItem() subroutine:

    Sub getItem( s as object, e as RepeaterCommandEventArgs )

    'response.write( "id: " + e.CommandSource.CommandArgument )

    Dim id as String = e.CommandSource.CommandArgument.ToString()

    Response.redirect( "buy.aspx?intID=" + id )

    End Sub

    As you can see, this subroutine picks up the value from the button control though the CommandArgument member. We could do lots of things with this now, but for simplicity's sake I have just chosen to hand it off to another page ('buy.aspx') with the ID of the desired product.

    More ASP.NET Articles
    More By Justin Cook


     

    ASP.NET ARTICLES

    - More Advanced ASP.NET 3.5 Functions and Subr...
    - ASP.NET 3.5 Functions and Subroutines
    - Coding an IQ Test with Conditionally Driven ...
    - Developing Conditionally Driven Event Handle...
    - ASP.NET 3.5 Debugging Using Visual Web Devel...
    - Understanding Event Handlers in ASP.NET 3.5
    - Building a Web Form in ASP.NET and PHP: a Co...
    - Inserting Data into a Microsoft SQL 2008 Dat...
    - Creating an ASP.NET Dynamic Web Page Using M...
    - Retrieving Data from Microsoft SQL Server 20...
    - Building ASP.NET Web Forms to Use a MySQL Da...
    - Creating an ASP.NET Database using MS SQL 20...
    - Building an ASP.NET Website Using Include Ta...
    - Create ASP.NET Web Forms to Use a Microsoft ...
    - Editing Web Design Layout in Visual Web Deve...





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek