Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i m getting total 10 columns in a row from db...

i want to show 5 columns in one row n other 5 in another row in gridvew..

i m having multiple rows returned frm db..

how to do???

i m creating web app.
Posted
Updated 31-May-12 8:39am
v2

1 solution

This behavior is typical of a listview.
You can solve using a listview like this:
ASP.NET
<h3>
    ListView split row</h3>
<asp:listview id="ListView2" datasourceid="SqlDataSource2" xmlns:asp="#unknown">
    ItemPlaceholderID="ContactItemContainer" runat="server">
    <layouttemplate>
        <table cellpadding="4" width="640px" runat="server" id="tblContacts">
            <tr id="Tr1" runat="server">
                <th id="Th1" colspan="3" runat="server">
                    Contacts
                </th>
            </tr>
            <tr runat="server" id="ContactItemContainer" />
        </table>
        <asp:datapager id="ContactsDataPager" runat="server" pagesize="30">
            <fields>
                <asp:numericpagerfield buttoncount="10" />
            </fields>
        </asp:datapager>
    </layouttemplate>
    <itemtemplate>
        <tr>
            <td id="Td8" class="item" runat="server">
                <asp:label id="Label2" runat="server" text="<%# Eval("TitleOfCourtesy") %>" />
            </td>
            <td id="Td5" class="item" runat="server">
                <asp:label id="NameLabel" runat="server" text="<%# Eval("LastName") %>" />
            </td>
            <td id="Td7" class="item" runat="server">
                <asp:label id="Label1" runat="server" text="<%# Eval("FirstName") %>" />
            </td>
        </tr><tr>
            <td id="Td9" class="item" runat="server">
                <asp:label id="Label3" runat="server" text="<%# Eval("Title") %>" />
            </td>
            <td id="Td10" class="item" runat="server">
                <asp:label id="Label4" runat="server" text="<%# Eval("City") %>" />
            </td>
            <td id="Td11" class="item" runat="server">
                <asp:label id="Label5" runat="server" text="<%# Eval("Country") %>" />
            </td>
        </tr>
    </itemtemplate>
    <itemseparatortemplate>
        <tr style="height:1px;">
        <td colspan="3" style="border-top: 1px solid #00C0C0; height:1px;">
            
        </td>
        </tr>
    </itemseparatortemplate>
</asp:listview>
<asp:sqldatasource id="SqlDataSource2" runat="server" connectionstring="<%$ ConnectionStrings:Northwind %>" xmlns:asp="#unknown">
    SelectCommand="SELECT [FirstName], [LastName] , [Title], [TitleOfCourtesy], [City], [Country]
        FROM Employees ORDER BY [LastName], [FirstName] "></asp:sqldatasource>
 
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