Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution 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
  #1 (permalink)  
Old May 31st, 2004, 10:50 AM
Authorized User
 
Join Date: Apr 2004
Location: ny, ny, Yemen.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datalist , Datagrid, or Repeater question

I have been battling over this for a while and cant seem to figure it out.How can you create a 2*2(2 column, 2 rows, 4 boxes) DATAGRID similar to the one in this page
http://www2.victoriassecret.com/coll...br=OSCLODNMJEA

(pls concentrate on the grid and not the ladies :D)

and also the multiple page effect. Is this a datagrd,datalist or a custom template?? and i suppose all the pictures are coming from one column in the database so how do they bind it to the grid and make it populate the top boxes then move to the next row??
Help will be greatly appreciated.

rrr
__________________
rrr
  #2 (permalink)  
Old May 31st, 2004, 11:10 AM
Authorized User
 
Join Date: Mar 2004
Location: , , United Kingdom.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The list show is a datalist with its repeat columns property set to 4. to achieve the two boxed effect, just create your own template for each item. The paging is the tricky part, as to get the page to only display 8 records per page this is required. You can go on google and search for DataList paging for more info.

The images, well the way i always do it (i am sure its not to everyones liking) is to have a thumbs directory under my images directory that holds all my thumbnail images. Within the database i have a column that holds the image name i.e. image1.jpg. then when i want to output it i just bind it as follows.

Code:
<asp:image
    ID=”image”
    ImageURL=’<%# “./images/thumbs/” & DataBinder.Eval(Container.DataItem, “ImageName” %>’
Runat=”server”/>
Hope that helps,

Rob

  #3 (permalink)  
Old May 31st, 2004, 12:18 PM
Authorized User
 
Join Date: Apr 2004
Location: ny, ny, Yemen.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Iam not to familiar with datalists, but i know it allows you to use html directly so do i bind my image column (image url) from database to the html columns 4 times to get a 4 by 4 grid?? wont that just display the same images 4 times???
I am pretty confused write now. here is my html grid similar to the link i posted before. If someone could help me transform it into the different sections of a datalist i will really appreciate it!!


<table width="512" border="0" cellpadding="0" cellspacing="0">

  <tr>
    <td width="252" height="280" valign="top" bgcolor="#CCCCCC">&nbsp;</td>
    <td width="8">&nbsp;</td>
    <td width="252" valign="top" bgcolor="#CCCCCC">&nbsp;</td>
  </tr>
  <tr>
    <td height="8"></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td height="1"></td>
    <td></td>
    <td rowspan="2" valign="top" bgcolor="#CCCCCC">&nbsp;</td>
  </tr>
  <tr>
    <td height="279" valign="top" bgcolor="#CCCCCC">&nbsp;</td>
    <td></td>
  </tr>
  <tr>
    <td height="2"></td>
    <td></td>
    <td></td>
  </tr>
</table>


rrr
  #4 (permalink)  
Old May 31st, 2004, 12:50 PM
Authorized User
 
Join Date: Mar 2004
Location: , , United Kingdom.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you have to remember that apart from the repeater the HTML table code is created for you by the control. For a datalist you can create the contents how ever you like, you can code HTML into it for instance and create a completly unique formatting for your items. But for what you want to achieve that is not really necessary, considering that you only want to create some basic formatting.

this could be useful, i havnt used a datalist for a bit so the exact code may not be this, but i am sure with some research you can find the exact code if the one below is wrong.

Code:
<asp:datalist
    ID="dg"
    repeatColumns="4"
    runat="server">
        <itemTemplate>
            <asp:image
                ID="image"
                imageURL='<%# "images/thumbs/" & DataBinder.Eval(Container.DataItem, "ImageName")%>'
                runat="server"/>
            <br>
            <asp:label
                ID="Test"
                Text='<%# DataBinder.Eval(Container.DataItem, "Text")%>'
                runat="server"/>
        </itemTemplate>    
</asp:datalist>
you can see i have created a new template and then binded the ImageName as an Image object and the Text as a Label object. The content wont be the same as if you are binding it to a datasource then whatever the record is, thats what will be displayed.

i.e.

ImageName - Text
Image1 - Test1
Image2 - Test2
Image3 - Test3

the list will loop and display all the records not just image1.

Rob



  #5 (permalink)  
Old May 31st, 2004, 02:10 PM
Authorized User
 
Join Date: Apr 2004
Location: ny, ny, Yemen.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for putting me on the right track RM82 i think i am finally starting to understand this stuff.

i went into "Edit item template for the "image" and "text" binding properties. This is the binding sentence it came up with

<%# DataBinder.Eval(dsshopping, "Tables[Products].DefaultView.[0].Images", "{0}") %>

<%# DataBinder.Eval(dsshopping, "Tables[Products].DefaultView.[0].ProductName", "{0}") %>

container.Item brings up an "undeclared item" error

rrr
  #6 (permalink)  
Old May 31st, 2004, 04:28 PM
Authorized User
 
Join Date: Apr 2004
Location: ny, ny, Yemen.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i finally got the syntax. In design view i can see the images as "databoud" but when i build all i get is a blank screen.

                    <table width="750" border="0" cellpadding="0" cellspacing="0" bgColor="#ffffff">

                <tr>
                    <td width="750" height="297" valign="top">
                        <asp:datalist id=dg runat="server" repeatColumns="2" DataSource='<%# dsshopping %>' ShowHeader="False" DataKeyField="ProductID" DataMember="Products" ShowFooter="False">
                            <ItemStyle BackColor="Silver"></ItemStyle>
                            <ItemTemplate>
                                <asp:image id=Image1 runat="server" ImageUrl='<%# "images/"+(DataBinder.Eval(Container, "DataItem.Images")) %>'>
                                </asp:image><BR>
                                <asp:label id=Label1 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.ProductName") %>'>
                                </asp:label>
                            </ItemTemplate>
                        </asp:datalist>
                    </td>
                </tr>
            </table>

rrr
  #7 (permalink)  
Old June 1st, 2004, 04:45 AM
Authorized User
 
Join Date: Mar 2004
Location: , , United Kingdom.
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

have you bound the grid?

i usually do my binding at the top of the aspx page on in my code behind file. If the syntax is correct then the only thing i can think of is the bind.
Code:
<Script Runat="server">

   Sub Page_Load(sender As Object, e As EventArgs)

      If Not IsPostBack Then
           dg.DataSource = dsShopping
           dg.DataBind()
      End If

  end Sub

</Script>
i usually create a sub that does all my page binding and place a call for it where the databind happens above.

Hope this helps,

Rob

  #8 (permalink)  
Old June 1st, 2004, 01:00 PM
Authorized User
 
Join Date: Apr 2004
Location: ny, ny, Yemen.
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

THANKS AGAIN RM82!!!
cant believe i forgot to bind the datalist. in all my confusion i guess i forgot to do the most basic thing. Now to tackle the paging thing........

rrr


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating DataGrid In Repeater/DataGrid liduwan ASP.NET 1.0 and 1.1 Professional 9 March 6th, 2007 03:31 PM
hyperlink in nested datalist calling a repeater debjanib C# 1 May 25th, 2006 08:17 AM
Master detail with datalist or repeater ceema ASP.NET 1.0 and 1.1 Professional 0 August 30th, 2005 03:20 PM
Suppress a column value in repeater, datalist ... jdang67 VS.NET 2002/2003 3 June 29th, 2005 09:47 PM





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