0

我正在尝试使用 ListView 控件显示数据库中的数据列表,如下所示:

员工姓名:xxxxxxxxx ID:111111 职位:yyyyyxxxx 组织:uuuuuu

这意味着我想在一个包含 4 列的表格中列出数据,其顺序如下: 属性 属性

我修改了以获得这种风格,我成功了。我现在的问题是在两个值列中从数据库中检索数据。我不知道该怎么做。

我的部分代码:

<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>
4

1 回答 1

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>

Eval 语句取决于您的数据源

于 2011-10-16T08:37:57.050 回答