我有一个实体我从Title(nvarchar(256)),Popularity(int)和Type(int)中拉出三列。然后我尝试在radiobuttonlist上使用QueryExtender,以允许最终用户过滤掉除特定结果之外的所有结果,但我不断收到“参数类型不匹配”错误。这是实际的代码:
<asp:QueryExtender ID="QueryExtender1" runat="server" TargetControlID="EntityDataSource1">
<asp:SearchExpression DataFields="Type" SearchType="StartsWith">
<asp:ControlParameter ControlID="rblTypes" PropertyName="SelectedValue" />
</asp:SearchExpression>
</asp:QueryExtender>
<asp:RadioButtonList ID="rblTypes" runat="server" AutoPostBack="True"
RepeatColumns="5" RepeatDirection="Horizontal">
<asp:ListItem Value="1">Active Inside</asp:ListItem>
<asp:ListItem Value="2">Semi-Active Inside</asp:ListItem>
<asp:ListItem Value="3">Inactive Inside</asp:ListItem>
<asp:ListItem Value="4">Chair Game</asp:ListItem>
<asp:ListItem Value="5">Active Outside</asp:ListItem>
<asp:ListItem Value="6">Semi-Active Outside</asp:ListItem>
<asp:ListItem Value="7">Inactive Outside</asp:ListItem>
<asp:ListItem Value="8">Water Game</asp:ListItem>
<asp:ListItem Value="9">Messy Game</asp:ListItem>
<asp:ListItem Value="10">Trick</asp:ListItem>
</asp:RadioButtonList>
有什么建议吗?
答案 0 :(得分:3)
猜猜:SelectedValue
是string
。它与Type
int
不匹配。您可以尝试在DbType
:
ControlParameter
<asp:ControlParameter ControlID="rblTypes" PropertyName="SelectedValue"
DbType="Int32" />
修改强>
asp:SearchExpression
似乎只适用于基于文本的搜索,这意味着您指定的数据字段必须是string
类型,而Type
列不是这种情况。您可以尝试asp:RangeExpression
而不是SearchExpression,并为最小值和最大值指定相同的值,即RadioButtonList的SelectedValue
:
<asp:QueryExtender ID="QueryExtender1" runat="server"
TargetControlID="EntityDataSource1">
<asp:RangeExpression DataField="Type" MinType="Inclusive" MaxType="Inclusive">
<asp:ControlParameter ControlID="rblTypes" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="rblTypes" PropertyName="SelectedValue" />
</asp:SearchExpression>
</asp:QueryExtender>