无法在ListView EmptyDataTemplate中显示SQL数据源中的值

时间:2013-10-04 14:25:29

标签: asp.net listview

我无法在ListView中显示SQL数据源的值。

使用下面的代码,显示中的'equipment_attrib_value_id'中保存的值很好(所以ahref链接有效)但是没有显示'equipment_attrib_value_id'中保存的值,这意味着链接只是指向AddAttribValue.aspx ?EquipmentID = 20&安培; HeadingID =

(所以没有值在HeadingID的末尾)

<asp:TemplateField HeaderText="modify" SortExpression="modify">
    <ItemTemplate>
    <asp:ListView ID="ListViewAttribModify" runat="server" 
        DataSourceID="SqlDataSourceAttribValues">
        <ItemTemplate>
        <tr style="">
            <td style="font-size:x-small;">
            <a href="EditAttribValue.aspx?ID=<%# Eval("equipment_attrib_value_id") %>">Edit</a>
            </td>
        </tr>
        </ItemTemplate>
        <LayoutTemplate>
        <table ID="itemPlaceholderContainer" runat="server" border="0" style="">
            <tr ID="itemPlaceholder" runat="server">
            </tr>
        </table>
        </LayoutTemplate>
        <EmptyDataTemplate>
        <table id="Table2" style="">
            <tr>
            <td style="font-size:x-small;">
                <a href="AddAttribValue.aspx?EquipmentID=<%=Request.QueryString("id") %>&HeadingID=<%# Eval("equipment_attrib_heading_id") %>">Add</a>
            </td>
            </tr>
        </table>
        </EmptyDataTemplate>
    </asp:ListView>
</ItemTemplate>
</asp:TemplateField>

'equipment_attrib_value_id'中保存的值确实存在,因为它正确地显示在。什么阻止我使用相同的值,更重要的是,我如何解决它/解决它?

1 个答案:

答案 0 :(得分:0)

EmptyDataTemplate只会在没有绑定到ListView的数据时显示(例如,你绑定了一个空集合),所以你的eval必然会返回null,因为根本就没有记录。

相关问题