Results 1 to 7 of 7

Thread: Suggestions for ASP.NET Data Repeater

  1. #1

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Suggestions for ASP.NET Data Repeater

    Right. Any suggestions on how to layout data to look like the following? I tried using a a web user control with a repeater in it, and for each different location create a new user web control and bind only the establishments applicable to that location to that repeater... but for some reason the repeaters or any other data controls aren't instantiated inside the web user control. Total pain in the bum.

    The salient fields in the Establishments table in relation to the image are:
    ID, Name, Area

    The ID is just the ID for each establishment, the name is the name (e.g. "Arklow Bay Confer....", "Glenart Castle Hotel", "Ballyknocked Coun..." etc. etc."), and the Area (e.g. Arklow, Ashford, Aughrim, Blessington).

    Any thoughts on how I could design my Repeater or Grid etc to display everything, but to group by the Area field as in the image?
    Attached Images Attached Images  
    Last edited by Wokawidget; Jan 16th, 2006 at 05:03 AM.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Suggestions for ASP.NET Data Repeater

    This is coming from a database, correct? And you have control over the recordset that is returned?

  3. #3

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Suggestions for ASP.NET Data Repeater

    Absolute and complete control yes
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Suggestions for ASP.NET Data Repeater

    Have two datatables filled up in your dataset.

    First:

    EstablishmentID+LongName

    Second:

    EstablishmentID+Area

    You can then add a relationship between them, and bind it to the repeater. Styling it as you wish of course.

    Here's an example:
    http://support.microsoft.com/default...b;en-us;326338

  5. #5

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Suggestions for ASP.NET Data Repeater

    Cool thanks I'll have a look at that!
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Suggestions for ASP.NET Data Repeater

    Post your code when it works. It's helpful for searches.

  7. #7

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Re: Suggestions for ASP.NET Data Repeater

    Didn't take too much tinkering to get it working. I'll post a fuller example in a little while...

    Code:
            <asp:Repeater id="parentRepeater" runat="server">
    	        <itemtemplate>
    		        <b>
    		         <%#DataBinder.Eval(Container.DataItem, "[Area Name]")%>
    		        </b>
    		        <br>
    		        <asp:Repeater id="childRepeater" runat="server" datasource='<%#Container.DataItem.Row.GetChildRows("myrelation")%>'>
    			        <itemtemplate>
    				        <%#Container.DataItem("Name")%><br>
    			        </itemtemplate>
    		        </asp:Repeater>
    	        </itemtemplate>
            </asp:Repeater>
    VB Code:
    1. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim cnn As SqlConnection = New SqlConnection("Data Source=localhost;Initial Catalog=SomeDB;Integrated Security=True;Pooling=False")
    3.         Dim cmd1 As SqlDataAdapter = New SqlDataAdapter("select * from areas", cnn)
    4.         Dim ds As DataSet = New DataSet()
    5.         cmd1.Fill(ds, "areas")
    6.  
    7.         Dim cmd2 As SqlDataAdapter = New SqlDataAdapter("select * from establishments", cnn)
    8.         cmd2.Fill(ds, "establishments")
    9.  
    10.         ds.Relations.Add("myrelation", ds.Tables("areas").Columns(0), ds.Tables("establishments").Columns(14))
    11.         parentRepeater.DataSource = ds.Tables("areas")
    12.  
    13.         Page.DataBind()
    14.         cnn.Close()
    15.     End Sub
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width