Forum Moderators: open

Message Too Old, No Replies

ASP Datagrid Templatefield question

How do you put the data into new columns instead of rows

         

lostie

11:53 am on Aug 24, 2007 (gmt 0)

10+ Year Member



Hi, our coding guy is on holidays for the week and I'm trying to sort out a problem i have, which im sure has a very simple solution but i know nothing really about asp. The code looks like:

<asp:GridView ID="gvbase" runat="server" AutoGenerateColumns="False" Width="100%" BorderWidth="0">
<Columns>
<asp:TemplateField HeaderText="Computer Books on Sale">
<ItemTemplate>
<table>
<tr>
<td>
<asp:Image ID="boxshot" runat="server" ImageUrl='<%# Bind("FP_image") %>' />
</td>
</tr>
<tr>
<td>
<asp:HyperLink ID="righttitle" runat="server" Text='<%# Bind("FP_title") %>' NavigateUrl='<%# Bind("FP_linkurl") %>'>
</asp:HyperLink>
</td>
</tr>
<tr>
<td>
<asp:HyperLink ID="rightauthor" runat="server" Text='<%# Bind("FP_author") %>' NavigateUrl='<%# Bind("FP_linkurl") %>' >
</asp:HyperLink>
</td>
</tr>
<tr>
<td>
<asp:HyperLink ID="rightprice" runat="server" Text='<%# Bind("FP_price") %>' NavigateUrl='<%# Bind("FP_linkurl") %>'>
</asp:HyperLink>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

Which takes an image and 3 pieces of text from another file (will eventually take it from a database) and results in the layout for a boxshot and product info. But when i put the info for the variables into the array list:


arlbase.Clear()
arlbase.Add(New clbooklayout("Book 1", "Author A", "€0.00", "image1.jpg", "http://www.example.com", ""))
arlbase.Add(New clbooklayout("Book 2", "Author B", "€0.00", "images2.jpg", "http://www.example.com", ""))
arlbase.Add(New clbooklayout("Book 3 ", "Author C", "€0.00", "image3.jpg", "http://www.example.com", ""))
gvbase.DataSource = arlbase
gvbase.DataBind()

it results in the table being produced 3 times, each one a different product. However they appear vertically, one after the other, and I want them to appear across, with the 3 in one row. Any idea how i can do this?

TheNige

3:41 am on Aug 25, 2007 (gmt 0)

10+ Year Member



I would suggest looking at the DataList control to see if that will work for you. It has things built in to do "so many columns across by this many rows".