wondery Posted January 6, 2004 Posted January 6, 2004 how to ? table that contain 10 cols and begin to new row ... Quote
sharpcoder Posted January 6, 2004 Posted January 6, 2004 Hello, wondery There are several ways to achieve this. If you want a simple alternative, complete out-of-the-box but maybe too complex for your needs, then you could use a datagrid which has built-in support for the thing you're describing. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagridclasstopic.asp You could also use a Repeater (that would be my choice) or an ordinary loop. With a repeater it would look something like this (in this example there are only two columns bt you'll see how to fix that). .aspx Here, usermessage and username are fields in my database. I get them from a datareader (next code block). <asp:Repeater id="repeater1" runat="server"> <HeaderTemplate> <table width="500"> </HeaderTemplate> <ItemTemplate> <tr> <td><%#DataBinder.Eval(Container.DataItem, "username")%> </td> <td><%#DataBinder.Eval(Container.DataItem, "usermessage")%> </td> </tr> </ItemTemplate> <SeparatorTemplate> <tr> <td colspan="2"> <hr /> </td> </tr> </SeparatorTemplate> <FooterTemplate> </table> </FooterTemplate> code behind: //create a datareader, reading information from your database and bind it to the repeater. repeater1.DataSource = myReader; repeater1.DataBind(); And you're all set! Quote
wondery Posted January 7, 2004 Author Posted January 7, 2004 <%@ Control Language="c#" AutoEventWireup="false" Codebehind="logo.ascx.cs" Inherits="car.logo" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> <asp:Repeater id="repeater1" runat="server"> <ItemTemplate> <table> <tr> <td><a href=list.aspx?BrandName='<%#DataBinder.Eval(Container.DataItem, "BrandName")%>'><img src='logo/<%#DataBinder.Eval(Container.DataItem, "Logo")%>' border="0"></a> </td> <td><a href=list.aspx?BrandName='<%#DataBinder.Eval(Container.DataItem, "BrandName")%>'><img src='logo/<%#DataBinder.Eval(Container.DataItem, "Logo")%>' border="0"></a> </td> <td><a href=list.aspx?BrandName='<%#DataBinder.Eval(Container.DataItem, "BrandName")%>'><img src='logo/<%#DataBinder.Eval(Container.DataItem, "Logo")%>' border="0"></a> </td> <td><a href=list.aspx?BrandName='<%#DataBinder.Eval(Container.DataItem, "BrandName")%>'><img src='logo/<%#DataBinder.Eval(Container.DataItem, "Logo")%>' border="0"></a> </td> <td><a href=list.aspx?BrandName='<%#DataBinder.Eval(Container.DataItem, "BrandName")%>'><img src='logo/<%#DataBinder.Eval(Container.DataItem, "Logo")%>' border="0"></a> </td> <td><a href=list.aspx?BrandName='<%#DataBinder.Eval(Container.DataItem, "BrandName")%>'><img src='logo/<%#DataBinder.Eval(Container.DataItem, "Logo")%>' border="0"></a> </td> <td><a href=list.aspx?BrandName='<%#DataBinder.Eval(Container.DataItem, "BrandName")%>'><img src='logo/<%#DataBinder.Eval(Container.DataItem, "Logo")%>' border="0"></a> </td> <td><a href=list.aspx?BrandName='<%#DataBinder.Eval(Container.DataItem, "BrandName")%>'><img src='logo/<%#DataBinder.Eval(Container.DataItem, "Logo")%>' border="0"></a> </td> <td><a href=list.aspx?BrandName='<%#DataBinder.Eval(Container.DataItem, "BrandName")%>'><img src='logo/<%#DataBinder.Eval(Container.DataItem, "Logo")%>' border="0"></a> </td> <td><a href=list.aspx?BrandName='<%#DataBinder.Eval(Container.DataItem, "BrandName")%>'><img src='logo/<%#DataBinder.Eval(Container.DataItem, "Logo")%>' border="0"></a> </td> </tr> <tr> <td class=smallfont><%#DataBinder.Eval(Container.DataItem, "BrandName")%> </td> <td class=smallfont><%#DataBinder.Eval(Container.DataItem, "BrandName")%> </td> <td class=smallfont><%#DataBinder.Eval(Container.DataItem, "BrandName")%> </td> <td class=smallfont><%#DataBinder.Eval(Container.DataItem, "BrandName")%> </td> <td class=smallfont><%#DataBinder.Eval(Container.DataItem, "BrandName")%> </td> <td class=smallfont><%#DataBinder.Eval(Container.DataItem, "BrandName")%> </td> <td class=smallfont><%#DataBinder.Eval(Container.DataItem, "BrandName")%> </td> <td class=smallfont><%#DataBinder.Eval(Container.DataItem, "BrandName")%> </td> <td class=smallfont><%#DataBinder.Eval(Container.DataItem, "BrandName")%> </td> <td class=smallfont><%#DataBinder.Eval(Container.DataItem, "BrandName")%> </td> </tr></table> </ItemTemplate> </asp:Repeater> almost but some prob ... it dont movenext how to ? Quote
sharpcoder Posted January 7, 2004 Posted January 7, 2004 I haven't seen your c#/vb.net code but I think you get a result something like this: 1 1 7 7 9 9 3 3 where it should be: 1 7 9 3 ? Well, that's because you're outputting the same value(s) two times in each iteration of the loop (you're actually not writing a loop, the repeater class saves that for you). You have for example <%#DataBinder.Eval(Container.DataItem, "BrandName")%> two times in each ItemTemplate. In you case I think you should look at: <SeparatorTemplate> and </SeparatorTemplate> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.