【发布时间】:2012-02-26 23:21:21
【问题描述】:
我使用下拉列表来优化我的 GridView。 Dropdownlist 绑定到 AccessDataSource(表类别)并有一个虚拟字段(请选择)。
<asp:Label ID="Label1" runat="server" Text="Refine your search"></asp:Label><br />
<asp:DropDownList ID="ddlCategories" runat="server" AppendDataBoundItems="True"
AutoPostBack="True" DataSourceID="ADC_Categories" DataTextField="CatedName"
DataValueField="Categ_Id">
<asp:ListItem Value="">-- please choose --</asp:ListItem>
</asp:DropDownList>
GridView(产品表)绑定到下拉列表,并将结果分别返回给选定的下拉列表值。但是,如果选择了虚拟字段 - 不返回数据(下拉列表中没有匹配的 CategoryID - 它的值为 null)
如何在选择伪字段时返回GridView中的所有记录?
感谢您的帮助。
【问题讨论】:
-
你的
SELECT声明是什么样的? -
SELECT [Product_Id], [ProductName], [Price], [ReleaseDate], [Promotion], [Genre_Id], [Category_Id] FROM [tblProduct] WHERE ([Category_Id] = ?) as I提到的参数来源是下拉列表(选择值)