1

I want to show my data in the format like below:

<table>
  <tr>
     <td></td>
     <td></td>
     <td></td>
     ...
  </tr>
  <tr>
     <td></td>
     <td></td>
     <td></td>
     ...
  </tr>
   .
   .
   .
</table>

I am bit confused about how to represent the data. I am thinking to use the repeater control for this structure. But will it need a nested repeater control or it can be done using the single repeater control? Can anybody please suggest me the proper way?

Thanks in advance.

Update :: In my case and are not in static order they are fully dynamic.In some cases may have the single but in some case they me be 10-20 in count.I need to show the score for test in those structure.for example:

<table>
  <tr>
    <td>10</td>
    <td>5</td>
    <td>30</td>
  </tr>
  <tr>
    <td>40</td>
    <td>34</td>
  </tr>
   .
   .
   .
<table>

like wise.In simple word when the score record for one user is completed I need to add new record in the new fresh .

gofor.net
  • 4,218
  • 10
  • 43
  • 65

4 Answers4

4

Why are you using repeater? It's rather obsolete component. Use ListView instead. It's much more flexible in configuration and manipulation.

Please use solution suggested here by Merrimack

<asp:ListView ID="myListView" runat="server" 
   DataSourceID="YOURDATASOURCE" GroupItemCount="3">

   <LayoutTemplate>
      <table>
         <tr>
            <td>
               <table border="0" cellpadding="5">
                  <asp:PlaceHolder runat="server" ID="groupPlaceHolder"></asp:PlaceHolder>
               </table>
            </td>
         </tr>
      </table>
   </LayoutTemplate>

   <GroupTemplate>
      <tr>
         <asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
      </tr>
   </GroupTemplate>

   <ItemTemplate>
      <td>
         <%# Eval("FullName") %>
      </td>
   </ItemTemplate>
</asp:ListView>
Community
  • 1
  • 1
Johnny_D
  • 4,592
  • 3
  • 33
  • 63
1

One solution from Old Classic way is nested loop

<table>
<% for(int loop1 = 0; loop1 <= condition1 ; loop1++){
       System.Console.WriteLine("<tr>");
       for(int loop2 = 0; loop2 <= condition2 ; loop2++){
           System.Console.WriteLine("<td>");
           System.Console.WriteLine("Your Data");
           System.Console.WriteLine("</td>");
       }
       System.Console.WriteLine("</tr>");
   } %>
</table>
RDSAGAR
  • 96
  • 4
0

You could make a Repeater like this

<asp:Repeater ID="rptMyRepeater" runat="server" >
     <HeaderTemplate>
          <table>
            <th>
               <td>
                  Header 1
               </td>
               <td>
                  Header 2
               </td>
             </th>
      </HeaderTemplate>
      <ItemTemplate>
          <tr>
             <td>
                 <asp:HiddenField runat="server" ID="hfHolderId" Value='<%# DataBinder.Eval(Container.DataItem, "HolderId") %>' />
                 <asp:TextBox runat="server" ID="tbText1" Text='<%# DataBinder.Eval(Container.DataItem, "Text1") %>' />
             </td>
             <td>
                 <asp:TextBox runat="server" ID="tbText2" Text='<%# DataBinder.Eval(Container.DataItem, "Text2") %>' />
             </td>
           </tr>
       </ItemTemplate>
       <FooterTemplate>
           </table>
       </FooterTemplate>
</asp:Repeater>

Then have a class to hold your data

    public class MyHolder()
    {
         public string HolderId {get;set;}
         public string Text1 {get;set;}
         public string Text2 {get;set;}
    }

Then make a list of these and bind them to your Repeater

    List<MyHolder> myHolderList = new List<MyHolder>();
    myHolderList.Add(new MyHolder {1, "hi", "hello"});
    //Add a few of these

    rptrptMyRepeater.DataSource = myHolderList;
    rptMyRepeater.DataBind();

All this was just outta my head so there my be syntax errors in there

Mikey Mouse
  • 2,968
  • 2
  • 26
  • 44
  • Oh and as Johhny D says, it is more elegant to use a ListView with a list of UserControls or something like that – Mikey Mouse Nov 15 '12 at 14:37
0

I finally done this with the dynamic table in asp.net.Like RDSAGAR did,but by code behind.Thanks for all your support.

gofor.net
  • 4,218
  • 10
  • 43
  • 65