Wrox Programmer Forums
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 23rd, 2009, 03:44 PM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default can repeater do "this"

i'd like to make my repeater spit things out in a grid type fashion. is this possible? or can the repeater only make a long list of stuff? currently i use it to display items in a store that can be purchased.
 
Old March 23rd, 2009, 11:21 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Repeaters are a good choice when you need to display data in, essentially, a table with 1 column and n number of rows. That is not to say you couldn't have a table style layout within each row, however.

When you say "grid type fashion" my mind automatically goes to the GridView. Is there any reason you are not using this control? What is it that you are ultimately trying to accomplish?

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
The Following User Says Thank You to dparsons For This Useful Post:
iceman90289 (March 25th, 2009)
 
Old March 24th, 2009, 01:17 AM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

something similar to how they are showing the products in a grid (this makes me think about looking at grid view because it has the word grid in it. haha) like at allfashiongo.com

when you look at say... shirts they have products in a grid. i was hoping the repeater could do that. but im starting to think it wasnt the best choice.
 
Old March 24th, 2009, 05:39 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

You can do this as a repeater in a very similar to the allfashiongo site and is probably a good solution in this case.
They just have a containing div with a fixed width, then have each individual item as a fixed width div with a "float:left;" style. As long as you fix the width and make sure nothing, like long text, makes it grow, it will lay out like a grid as their one does.
Other controls like gridviews are not really practical for this as each item takes up one full row and you want 3 or 4 in each row.

Phil
The Following User Says Thank You to philip_cole For This Useful Post:
iceman90289 (March 25th, 2009)
 
Old March 24th, 2009, 11:56 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Based on the current design of that site, I would not use a repeater. First off there is no consistent design between sections. For example, take a look at Pants/Jeans. Notice that each item is displayed in its own row and the items expand far down the page. Now, flip over to Plus Sizes and see how there are n number of products per row?

I think that if you are going to take the repeater approach (and thus the Pants/Jeans interface style) you need to be able to utilize all of the negative space that is going to be created. Personally I prefer the Plus Size approach which can be done by using a DataList.

My two cents anyway.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
The Following User Says Thank You to dparsons For This Useful Post:
iceman90289 (March 25th, 2009)
 
Old March 24th, 2009, 03:11 PM
Friend of Wrox
 
Join Date: Mar 2008
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

thanks guys.

as far as the sites inconsistent design... it was made by multiple people because this idiot tried to "play buisiness-man" and threw a team of random people together and created a demo-site so that he could present it to a client and say "this is what we will make for you" and his client thought "wow this site sucks. lets make it look like it was made by one person. with a consistent design and some kind of theme."

thats kind of where i might come in. (if they decide to go with me) im redoing this with asp.net. and im going to make the products list out in a grid.
 
Old March 24th, 2009, 03:45 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

Quote:
Originally Posted by dparsons View Post
For example, take a look at Pants/Jeans. Notice that each item is displayed in its own row and the items expand far down the page. ...
I think that if you are going to take the repeater approach (and thus the Pants/Jeans interface style)

Doug,
Please correct me if I'm misunderstanding your last post, but why do repeaters necessarily have to have items on separate "rows"?

Code:
<%@ Page Language="C#" %>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
    string[] arrProducts = new string[] {
        "W8-32475-GRAY Skirt", "4953 Navy Vintage Shorts", "4953 Brown Vintage Shorts",
        "4953 White Vintage Shorts", "4952A Stone Vintage Shorts", "4952A Black Vintage Shorts",
        "4952A Olive Vintage Shorts", "61085HL Aqua Denim Bermuda", "61085HL Cherry Denim Bermuda",
        "61085HL Blue Denim Bermuda", "61085HL DK Orange Bermuda", "61085HL Green Denim Bermuda",
        "61085HL HotPink Denim Bermuda", "61085HL Orange -Denim Bermuda", "61085HL Pink Denim Bermuda"
    };

    Products.DataSource = arrProducts;
    Products.DataBind();
}
</script>
<html>
<head></head>
<body>
    <form id="form1" runat="server">
    <asp:Repeater runat="server" ID="Products">
    <ItemTemplate>
        <div style="float:left; width:200px; margin:15px;">
          <div><img src="http://www.allfashiongo.com/4952AoliveT.jpg" /></div>
          <div><%# Container.DataItem %></div>
        </div>
    </ItemTemplate>
    </asp:Repeater>
    </form>
</body>
</html>
Phil
The Following User Says Thank You to philip_cole For This Useful Post:
iceman90289 (March 25th, 2009)
 
Old March 24th, 2009, 04:01 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Phil, nice use of CSS.

I am talking about the default behavior of a repeater, of course, where it will simply "stack" each individual item "on top" of each other. Where as a datalist can be configured to do what you have done with CSS through setting a few properties.

To be honest I would not have come up with that CSS since I am not a UI guy at all (unless of course you want black text on a white background then im your guy!) though it does further prove the statement that there is more than one way to achieve the same end through programming. Good example.

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
The Following User Says Thank You to dparsons For This Useful Post:
iceman90289 (March 25th, 2009)
 
Old March 24th, 2009, 05:17 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Or, since you're using ASP.NET 3.5, use the new ListView control.

It has the main features of all data driven controls (repeat the data, Item and AlternatingItem templates, paging, inserting and so on), while you still maintain full control over the markup so you can create a fluid layout as Phil is suggesting....

Code:
 
<%@ Page Language="C#" %>
<script runat="server">
  void Page_Load(object sender, EventArgs e)
  {
    string[] arrProducts = new string[] {
        "W8-32475-GRAY Skirt", "4953 Navy Vintage Shorts", "4953 Brown Vintage Shorts",
        "4953 White Vintage Shorts", "4952A Stone Vintage Shorts", "4952A Black Vintage Shorts",
        "4952A Olive Vintage Shorts", "61085HL Aqua Denim Bermuda", "61085HL Cherry Denim Bermuda",
        "61085HL Blue Denim Bermuda", "61085HL DK Orange Bermuda", "61085HL Green Denim Bermuda",
        "61085HL HotPink Denim Bermuda", "61085HL Orange -Denim Bermuda", "61085HL Pink Denim Bermuda"
    };
    Products.DataSource = arrProducts;
    Products.DataBind();
  }
</script>
<html>
<head>
  <title></title>
  <style type="text/css">
    .Even
    {
      color: Red;
    }
  </style>
</head>
<body>
  <form id="form1" runat="server">
    <asp:ListView runat="server" ID="Products">
      <LayoutTemplate>
        <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
      </LayoutTemplate>
      <AlternatingItemTemplate>
        <div style="float: left; width: 200px; margin: 15px;" class="Even">
          <div>
            <img src="http://www.allfashiongo.com/4952AoliveT.jpg" alt="Short" /></div>
          <div>
            <%# Container.DataItem %></div>
        </div>
      </AlternatingItemTemplate>
      <ItemTemplate>
        <div style="float: left; width: 200px; margin: 15px;">
          <div>
            <img src="http://www.allfashiongo.com/4952AoliveT.jpg" alt="Short" /></div>
          <div>
            <%# Container.DataItem %></div>
        </div>
      </ItemTemplate>
    </asp:ListView>
  </form>
</body>
</html>
Of course you may be better off using jQuery for these kind of presentational issues, but that's a different discussion....;-)

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!

Last edited by Imar; March 24th, 2009 at 05:19 PM..
The Following 2 Users Say Thank You to Imar For This Useful Post:
iceman90289 (March 25th, 2009), philip_cole (March 24th, 2009)
 
Old March 24th, 2009, 06:01 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Quote:
Originally Posted by Imar View Post
Of course you may be better off using jQuery for these kind of presentational issues, but that's a different discussion....;-)
OR ExtJS. mmmmm. ;]
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
The Following User Says Thank You to dparsons For This Useful Post:
iceman90289 (March 25th, 2009)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Code not going as planned: "icicle" vs "savedinstancestate" joopthecat BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 May 3rd, 2009 03:09 PM
Chapter-5 on Intents:ContactPickerTester does not show the button "Pick a Contact" sunilm12 BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 3 April 15th, 2009 11:55 AM
how to read xml files doing select="document()" ? eruditionist XSLT 2 February 10th, 2009 05:08 PM
Message received by "FILE" adapter is suspended skindika Biztalk 0 February 2nd, 2009 07:06 PM
WebPart not supporting/enabled displaymode other than "Browse" amitjoshipune ASP.NET 2.0 Professional 1 January 9th, 2009 02:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.