ASP.NET
  Home arrow ASP.NET arrow Page 2 - 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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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 - Get the Data


    (Page 2 of 5 )

    Let's start off by assuming that you've got all of product information stored in a database. This article will not go into creating or populating a database, but it is assumed that you've mastered the basics (by basic, I mean Microsoft Access). I will assume you have the following fields in a 'products' table, in an Access database:

    id description manufacturer color price imgPath

    This is by no means a normalized database we're dealing with here, nor does it need to be for the sake of teaching how to use a Repeater. Most of the fields are self-descriptive, however the 'imgPath' will be pointing to the relative path of a picture of the product. This is not absolutely necessary, but it's a good idea, and it's also a nice way to show off the flexibility of the Repeater, as you will see.

    This article is not a tutorial on data retrieval either. I will though, include the necessary code to do the data extraction from the database, with a small explanation of what's going on. We will need a subroutine called doBinding(), which will do the data retrieval, and the binding.

    Sub doBinding()

    Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0; " & _

    "Ole DB Services=-4; " & _

    "Data Source=C:\Inetpub\wwwroot\store.mdb"

    Dim dbConnection As OleDbConnection = New OleDbConnection(strConn)


    Dim strSQL As String = "SELECT * FROM products"


    Dim dataAdapter As OleDbDataAdapter = New OleDbDataAdapter( strSQL, strConn)


    Dim dataSet As DataSet = New DataSet

    dataAdapter.Fill(dataSet)

    We've done the all the needed work to extract the data into a dataset, and all that's left is to tell the repeater to use that data. Do that by 'binding', or attaching, it to the dataset. We'll assume the name of the repeater will be prodRepeater:

    prodRepeater.DataSource = dataSet

    prodRepeater.DataBind()

    End Sub

    Now add in the code responsible for calling this subroutine and populating the repeater the first time the page is loaded:

    sub page_load( source as Object, e as EventArgs )

    if not isPostBack then

    doBinding()

    end if

    end sub

    More ASP.NET Articles
    More By Justin Cook


     

    ASP.NET ARTICLES

    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT