max table columns in Repeater control

Discussion in 'ASP .Net' started by Brian W, May 16, 2004.

  1. Brian W

    Brian W Guest

    I have an array of strings:

    s[0] = "string 0";
    s[1] = "string 1";
    s[2] = "string 2";
    s[3] = "string 3";
    s[4] = "string 4";
    s[5] = "string 5";
    s[6] = "string 6";
    s[7] = "string 7";
    s[8] = "string 8";
    s[9] = "string 9";
    s[10] = "string 10";

    and I want to display them in a table using a Repeater(?) like this:

    "string 0" "string 1" "string 2" "string 3" "string 4"
    "string 5" "string 6" "string 7" "string 8" "string 9";
    "string 10"

    Is something like this possible with a Repeater? How? Example?


    TIA
    Brian W
     
    Brian W, May 16, 2004
    #1
    1. Advertising

  2. Brian W

    Natty Gur Guest

    Hi,

    Yes it possible but with DataList:

    you need to add lable to your DataList and bind it to container
    dataitem. then set your array as DataList datasource and bind array to
    DataList:

    Page ASPX file :

    <asp:DataList id="DataList2" style="Z-INDEX: 106; LEFT: 219px; POSITION:
    absolute; TOP: 270px"
    runat="server" Height="82" Width="231" RepeatDirection="Horizontal"
    RepeatColumns="4">
    <ItemTemplate>
    <asp:Label id=Label1 runat="server" Text='<%#
    DataBinder.Eval(Container, "DataItem") %>'>
    </asp:Label>
    </ItemTemplate>
    </asp:DataList>

    page code behind :

    string[] s = new string[11];
    s[0] = "string 0";
    s[1] = "string 1";
    s[2] = "string 2";
    s[3] = "string 3";
    s[4] = "string 4";
    s[5] = "string 5";
    s[6] = "string 6";
    s[7] = "string 7";
    s[8] = "string 8";
    s[9] = "string 9";
    s[10] = "string 10";

    this.DataList2.DataSource = s;
    DataList2.DataBind();

    Natty Gur[MVP]

    blog : http://weblogs.asp.net/ngur
    Mobile: +972-(0)58-888377


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Natty Gur, May 17, 2004
    #2
    1. Advertising

  3. Hi Brian,

    Based on my understanding, you want to display a string array every 5 items
    per row in a table in Asp.net.

    Instead of using Repeater control, I think DataList may be more suitable
    for you. Do like this:

    private void Page_Load(object sender, System.EventArgs e)
    {
    string [] arr=new string[11];
    for(int i=0;i<11;i++)
    {
    arr="string"+i;
    }
    this.DataList1.DataSource=arr;
    this.DataList1.DataBind();
    }

    <asp:DataList id="DataList1" RepeatColumns="5" RepeatDirection="Horizontal">
    <ItemTemplate>
    <%# Container.DataItem.ToString()%>
    </ItemTemplate>
    </asp:DataList>

    =============================
    Please apply my suggestion above and let me know if it helps resolve your
    problem.

    Thank you for your patience and cooperation. If you have any questions or
    concerns, please feel free to post it in the group. I am standing by to be
    of assistance.

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
     
    Jeffrey Tan[MSFT], May 17, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John
    Replies:
    1
    Views:
    4,815
    Ingo R. Homann
    Sep 26, 2006
  2. Jacksm
    Replies:
    2
    Views:
    861
    Paul Chalekian
    Nov 21, 2006
  3. Summercool
    Replies:
    9
    Views:
    903
    dorayme
    Oct 23, 2007
  4. Greg Ferris

    Textarea max rows and max characters per row

    Greg Ferris, Jan 16, 2004, in forum: Javascript
    Replies:
    2
    Views:
    612
    Greg Ferris
    Jan 16, 2004
  5. kriton
    Replies:
    0
    Views:
    349
    kriton
    Apr 22, 2005
Loading...

Share This Page