参数类型与 QueryExtender 不匹配
我有一个实体,我从标题 (nvarchar(256))、流行度 (int) 和类型 (int) 中提取三列。然后,我尝试在单选按钮列表上使用 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>
有什么建议吗?
I have an Entity I'm pulling three columns from Title (nvarchar(256)), Popularity (int), and Type (int). I'm then trying to use QueryExtender on a radiobuttonlist to allow the end user to filter out all but specific results but I keep getting an "Argument Types do not match" error. Here is the actual code:
<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>
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是猜测:
SelectedValue
是一个字符串
。它与Type
不匹配,后者是一个int
。您可以尝试在ControlParameter
中明确指定DbType
:Edit
asp:SearchExpression
似乎仅适用于文本基于搜索,这意味着您指定的数据字段必须是string
类型,而您的Type
列则不是这种情况。除了 SearchExpression,您还可以尝试使用asp:RangeExpression
并为最小值和最大值指定相同的值,即 RadioButtonList 的SelectedValue
:Just a guess:
SelectedValue
is astring
. It doesn't match withType
which is anint
. You could try to specify theDbType
explicitely in theControlParameter
:Edit
asp:SearchExpression
seems only to be for text based search which means that the data fields you specify must be of typestring
which is not the case for yourType
column. Instead of a SearchExpression you could try anasp:RangeExpression
and specify the same value for minimum and maximum, namely theSelectedValue
of the RadioButtonList: