Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么我的数据列表只显示第一个图像?_C#_Asp.net_Visual Studio - Fatal编程技术网

C# 为什么我的数据列表只显示第一个图像?

C# 为什么我的数据列表只显示第一个图像?,c#,asp.net,visual-studio,C#,Asp.net,Visual Studio,我有一个db,它包含有以下列的产品:image1、image2、image3。我正在显示这个数据列表,只有第一张图片出现在那里。在其他图像上,我看到重定向很好,但它没有显示它们 标记: <asp:DataList ID="DataList2" runat="server" DataKeyField="ID" DataSourceID="SqlDataSource1"> <ItemTemplate> <table>

我有一个db,它包含有以下列的产品:image1、image2、image3。我正在显示这个数据列表,只有第一张图片出现在那里。在其他图像上,我看到重定向很好,但它没有显示它们

标记:

<asp:DataList ID="DataList2" runat="server" DataKeyField="ID" DataSourceID="SqlDataSource1">
        <ItemTemplate>
            <table>
                <tr>
                    <td rowspan="2">
                        <asp:HyperLink ID="HyperLink3" runat="server" ImageUrl='<%# Eval("image1", "{0}") %>' data-lightbox="imageset" Height="150px" Width="150px" ImageHeight="150px" ImageWidth="150px" NavigateUrl='<%# Eval("image1", "{0}") %>'></asp:HyperLink>
                    </td>
                    <td width="600px"><asp:Label ID="nazwaLabel" runat="server" Text='<%# Eval("nazwa") %>' CssClass="produktNazwa" />
                </tr>
                <tr>
                    <td><asp:Label ID="cenaLabel" runat="server" Text='<%# Eval("cena", "{0} PLN") %>' CssClass="produktCena" /> </td>
                </tr>
                <tr>
                    <td>
                        <asp:HyperLink ID="HyperLink4" runat="server" ImageUrl='<%# Eval("image2", "{0}") %>' data-lightbox="imageset" Height="150px" Width="150px" ImageHeight="150px" ImageWidth="150px" NavigateUrl='<%# Eval("image2", "{0}") %>'></asp:HyperLink>
                    </td>
                    <td><asp:Label ID="opisLabel" runat="server" Text='<%# Eval("opis") %>' CssClass="produktOpis" /></td>
                </tr>
                <tr>
                    <td>
                        <asp:HyperLink ID="HyperLink5" runat="server" ImageUrl='<%# Eval("image3", "{0}") %>' data-lightbox="imageset" Height="150px" Width="150px" ImageHeight="150px" ImageWidth="150px" NavigateUrl='<%# Eval("image3", "{0}") %>'></asp:HyperLink>
                    </td>
                </tr>
            </table>
        </ItemTemplate>
    </asp:DataList>


<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Produkty] WHERE ([ID] = @ID)">
        <SelectParameters>
            <asp:ControlParameter ControlID="Label1" Name="ID" PropertyName="Text" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>


有什么想法吗?

您有一个查询
SELECT*来自[Produkty],其中([ID]=@ID)
显然只返回一个结果。是的,但它返回每个产品的所有3列。所以我应该可以访问这些图像1、2和3。但是我怎样才能访问这个?它返回的url路径很好,但没有显示图像本身。从这里我可以看到,我同意@dotnetom。假设ID是每个条目唯一的值(例如键或伪键),这种类型的查询只能返回1行。如果您确定您的查询是正确的???我想您需要向我们展示一个返回的数据方案示例,例如3列及其典型数据的示例。超链接绑定到行的其他列。它正确地显示了其他数据,如产品名称、说明、价格等,但不显示image2和imgae3,但它正确地读取了指向它们的url。