0

I am trying to use the ListView control to show a list of data from the database as following:

Employee Name: xxxxxxxxx ID: 111111 Job Title: yyyyyxxxx Organization: uuuuuu

which means I want to list the data in a table of 4 columns that orders as following: Property Value Property Value

I modified the to get this style and I succeeded. My problem now is to retrieve data from the database in both value columns. I don't know how to do that.

Part of my code:

<LayoutTemplate>
    <table border="0" cellpadding="1">
        <tr style="background-color:#003366; color:white">
            <th align="left"> Employee Name </th>
            <td>
            </td>

            <th align="left">ID</th>
            <td></td>
        </tr>

        <tr style="background-color:#003366; color:white"> 
            <th align="left">Job Title.</th>
            <td></td>

            <th align="left">Organization</th>
            <td></td>
        </tr>


        <tr id="itemPlaceholder" runat="server">
        </tr>

    </table>
</LayoutTemplate>
user976711
  • 115
  • 5
  • 16
  • Look at these links: [how to add the items coming from the database to the list view using asp.net and c#](http://weblogs.asp.net/scottgu/archive/2007/08/10/the-asp-listview-control-part-1-building-a-product-listing-page-with-clean-css-ui.aspx) (excellent meterial from scottgu) and [Complete Listview](http://www.codeproject.com/KB/webforms/CompleteListView.aspx). – Glory Raj Oct 16 '11 at 07:05

1 Answers1

1
    <LayoutTemplate>
        <table border="0" cellpadding="1">
            <tr style="background-color:#003366; color:white">
                <th align="left"> Employee Name </th>
                <td>
                </td>

                <th align="left">ID</th>
                <td></td>
            </tr>

            <tr style="background-color:#003366; color:white"> 
                <th align="left">Job Title.</th>
                <td></td>

                <th align="left">Organization</th>
                <td></td>
            </tr>
            <asp:PlaceHolder id="itemPlaceholder" runat="server" />

        </table>
    </LayoutTemplate>
    <ItemTemplate>
            <tr style="background-color:#003366; color:white">
                    <td align="left"></td>    
                    <td><%# Eval("EmployeeName")%></td>

                    <td align="left"></td>
                    <td><%# Eval("ID")%></td>
                </tr>

                <tr style="background-color:#003366; color:white"> 
                    <td align="left"></td>
                    <td><%# Eval("JobTitle")</td>

                    <td align="left"></td>
                    <td><%# Eval("Organization")</td>
                </tr>
    </ItemTemplate>

The Eval statements depend on your datasource

Adrian Iftode
  • 15,465
  • 4
  • 48
  • 73