2011-05-03 90 views
1

我有一個實體我從Title(nvarchar(256)),Popularity(int)和Type(int)拉三列。然後,我試圖在radiobuttonlist上使用QueryExtender,以允許最終用戶篩選出除特定結果以外的所有結果,但我一直收到「參數類型不匹配」錯誤。這裏是實際的代碼:參數類型不匹配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> 

有什麼建議嗎?

回答

3

只是猜測:SelectedValuestring。它與Type這是一個int不匹配。您可以嘗試顯式地指定DbTypeControlParameter

<asp:ControlParameter ControlID="rblTypes" PropertyName="SelectedValue" 
    DbType="Int32" /> 

編輯

asp:SearchExpression看來只有是基於文本的搜索,這意味着您指定的數據字段必須string型這是而不是你的Type列的情況。取而代之的是SearchExpression的你可以嘗試的asp:RangeExpression和最小值和最大值,在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> 
+0

是啊,我猜是相同的。不幸的是,我嘗試了你的建議,也沒有奏效。 :( – davemackey 2011-05-03 13:23:45

+1

@dave:我有一個新理論;)看我的編輯... – Slauma 2011-05-03 14:06:07