如何在datadown视图中根据下拉列表项显示db中的数据

时间:2015-01-10 14:26:11

标签: c# html sql asp.net datalist

我想根据下拉菜单中选定的项目在数据列表视图中显示我的数据。

我已将数据与我的数据列表视图绑定,它显示除图像之外的所有数据列。

我应该如何从数据库中显示我的图像数据..根据下拉列表中的选定项目,它应该响应,但它没有显示任何响应..

我没有使用逻辑背后的任何代码。我已经在向导的帮助下完成了生成查询并将特定数据与我的数据库绑定,并将数据显示到其各自的控件。 如果有人做了相关的工作..请注释掉 感谢..

这是我目前的代码

<strong><span class="auto-style2">I wanna see: </span></strong>&nbsp;<strong><asp:DropDownList ID="DropDownList1" runat="server" Height="44px" Width="214px" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" CssClass="auto-style3" DataTextField="Brand" DataValueField="Brand">
    <asp:ListItem Selected="True">clothes</asp:ListItem>
    <asp:ListItem>jewelry</asp:ListItem>
    <asp:ListItem>shoes</asp:ListItem>
</asp:DropDownList>

</strong>


<asp:DataList ID="DataList1" runat="server" RepeatColumns="3" RepeatDirection="Horizontal"
    Width="99%" BorderColor="Blue" BorderStyle="Solid" BorderWidth="3px" DataSourceID="SqlDataSource1" Height="456px">
    <ItemTemplate>
        Brand:
        <asp:Label ID="BrandLabel" runat="server" Text='<%# Eval("Brand") %>'></asp:Label>


        <br />
        <br />


        Image:<br />
        <br />
        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Image") %>' />


        <br />

        <br />
        Price:
        <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' />
        <br />
        <br />
        Description:
        <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />

        <br />
        <br />


    </ItemTemplate>
    <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" />
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:loginString %>" SelectCommand="SELECT [Brand], [Price], [Image], [Description] FROM [w_product] WHERE ([Category] = @Category)">
    <SelectParameters>
        <asp:ControlParameter ControlID="DropDownList1" DefaultValue="clothes" Name="Category" PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
</asp:SqlDataSource>

0 个答案:

没有答案