Click here to Skip to main content
15,885,178 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
What basically i want to do is , to show the records i get in datatable in different HTML tables. The records in the datatable has 3 coloums and i can have at the max 6 records.

the datatable i am getting from the database is as follows:
C#
Name  Age

XYZ   30

XY1   31

XY2   32

XY3   33
and i want to show the records in the following way:
C#
name age  name age

 XYZ  30   XY1  31

name age name age

XY2  32   XY3   33



Total Strength of employees : 4

what currently i am doing is as follows:
ASP.NET
<asp:Repeater ID="RptNCode" runat="server" OnItemCommand="RptNcode_ItemCommand"
                                                        OnItemDataBound="RptNCode_ItemDataBound">
                                                        <HeaderTemplate>
                                                            <tr style="background-color: #507CD1; color: White; font-weight: bold; text-align: center;
                                                                height: 20px">
                                                                <td style="color: White;">
                                                                    Sr.No
                                                                </td>
                                                                <td style="color: White; text-align: left">
                                                                    Name
                                                                </td>
                                                                <td style="color: White; text-align: right">
                                                                     Age 
                                                                </td>
                                                            </tr>
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                       <tr style="background-color: #ffffff; height: 20px; font-family: Arial">
                                                                
                                                                <td align="left" style="font-size: 15;">
                                                                    <asp:LinkButton ID="lnkNCode" ForeColor="#336699" runat="server" Text='<%# Eval("Name") %>'
                                                                        CommandArgument='<%# Eval("Name") %>' CommandName="NCode"></asp:LinkButton>
                                                                </td>
                                                                <td align="center" style="font-size: 15; text-align: right;">
                                                                    <%#  Eval("Age")%>
                                                                     
                                                                </td>
                                                            </tr>
                                                        </ItemTemplate>
                                                        <AlternatingItemTemplate>
                                                            <tr style="background-color: #ffffff; height: 20px; font-family: Arial">
                                                                
                                                                <td align="left" style="font-size: 15;">
                                                                    <asp:LinkButton ID="lnkNCode" ForeColor="#336699" runat="server" Text='<%# Eval("Name") %>'
                                                                        CommandArgument='<%# Eval("Name") %>' CommandName="NCode"></asp:LinkButton>
                                                                </td>
                                                                <td align="center" style="font-size: 15; text-align: right;">
                                                                    <%#  Eval("Age")%>
                                                                     
                                                                </td>
                                                            </tr>
                                                        </AlternatingItemTemplate>
                                                        <FooterTemplate>
                                                            <tr>
                                                                
                                                                <td align="right" height="40px">
                                                                    <asp:Label ID="lblTotal" runat="server" Font-Bold="true" ForeColor="#336699"></asp:Label>
                                                                     
                                                                </td>
                                                            </tr>
                                                        </FooterTemplate>
                                                    </asp:Repeater>


I know that it is not correct but this what i have done . Is the thing which i want to do is possible or not ?

Thanks
Posted
Updated 24-Jul-14 0:50am
v3

1 solution

Above scenario depends on the number of records you will be fetch from the database.

you need to distribute the values in to two extra columns by using loop
for the distribution you can take
generic list if you are doing in code or
if you want to do all things in sql server then you can take temp variable or table
for the same its depends on the situation.

convert the data in your desired format and then bind with the grid.
repeater can be use for the same and you can put some logic in it also.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900