2010-08-05 64 views
1

我有一個帶有網格視圖的ASP.Net網頁。我想根據下拉列表的選擇過濾網格視圖數據。我在另一個頁面上正常工作。問題頁面上的區別在於我需要過濾的列是int而不是varchar。當我加載頁面時,我收到錯誤消息:輸入字符串格式不正確。ASP.Net SQLDataSource篩選器 - 輸入字符串格式不正確

我已經粘貼下面的下拉列表和數據源的代碼。這一定是一個共同的要求,所以我想我錯過了明顯的東西......?試圖通過谷歌尋找解決方案時,其他人也有同樣的問題。可以在http://www.velocityreviews.com/forums/t123088-problem-in-filterparameters.html找到非常類似的帖子,不幸的是,加文的決議對我沒有幫助。

非常感謝,

Rob。

<%@ Page Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="BacheAccountSettings.aspx.cs" 
Inherits="RDM.BacheTradeLoad" Title="Untitled Page" %> 

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> 
<tr> 
    <td style="width: 100px;"> 
     Filter: 
    </td> 
    <td style="width: 170px;"> 
     <asp:DropDownList ID="ddlAccountSourceId" DataSourceID="dsAccountSourceId" AutoPostBack="true" 
      DataValueField="AccountId" runat="server" Width="130px" Font-Size="11px" AppendDataBoundItems="true"> 
      <asp:ListItem Text="All" Value="%"></asp:ListItem> 
     </asp:DropDownList> 
    </td> 
</tr> 
<tr> 
    <td colspan="1"> 
     <asp:GridView ID="grdRefBacheAccount" runat="server" AutoGenerateColumns="False" 
      BackColor="White" BorderColor="#E7E7FF" BorderWidth="1px" CellPadding="3" DataSourceID="dsArcReference" 
      GridLines="Horizontal" BorderStyle="None" EnableModelValidation="True" Style="position: static" 
      OnRowDataBound="grdRefBacheAccount_RowDataBound" AllowPaging="True" PageSize="25" 
      CssClass="Grid" AllowSorting="True"> 
      <Columns> 
       <asp:CommandField ShowEditButton="True" ShowCancelButton="False" /> 
       <asp:BoundField DataField="SourceID" HeaderText="SourceID" SortExpression="SourceID" /> 
       <asp:BoundField DataField="GroupCompany" HeaderText="GroupCompany" SortExpression="GroupCompany" /> 
       <asp:BoundField DataField="Portfolio" HeaderText="Portfolio" SortExpression="Portfolio" /> 
       <asp:BoundField DataField="OnBehalfComp" HeaderText="OnBehalfComp" SortExpression="OnBehalfComp" /> 
       <asp:BoundField DataField="AssignedTrader" HeaderText="AssignedTrader" SortExpression="AssignedTrader" /> 
      </Columns> 
      <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> 
      <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" /> 
      <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /> 
      <SelectedRowStyle BackColor="#738A9C" ForeColor="#F7F7F7" Font-Bold="True" /> 
      <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /> 
      <AlternatingRowStyle BackColor="#F7F7F7" /> 
     </asp:GridView> 
    </td> 
</tr> 
<div id="divImportButton" align="right"> 
    <asp:Button ID="btnImport" runat="server" Text="Import Trade" OnClick="btnImport_Click" 
     CssClass="Button" /> 
</div> 
<asp:SqlDataSource ID="dsArcReference" runat="server" ConnectionString="<%$ ConnectionStrings:ARC_REFERENCEConnectionString %>" 
    SelectCommand="select ACCOUNT_SOURCE_ID as 'AccountId', 
        [ACCOUNT_BTF_GROUP_COMPANY] as 'GroupCompany', 
        [ACCOUNT_BTF_PORTFOLIO] as 'Portfolio', 
        [ACCOUNT_BTF_ON_BEHALF_COMPANY] as 'OnBehalfComp', 
        [ACCOUNT_BTF_ASSIGNED_TRADER] as 'AssignedTrader' 
        from dbo.REF_BACHE_ACCOUNT" UpdateCommand="update dbo.REF_BACHE_ACCOUNT 
       set [ACCOUNT_BTF_GROUP_COMPANY] = @GroupCompany, 
       [ACCOUNT_BTF_PORTFOLIO] = @Portfolio, 
       [ACCOUNT_BTF_ON_BEHALF_COMPANY] = @OnBehalfComp, 
       [ACCOUNT_BTF_ASSIGNED_TRADER] = @AssignedTrader 
       where [ACCOUNT_SOURCE_ID][email protected]" FilterExpression="SourceID={0}"> 
    <FilterParameters> 
     <asp:ControlParameter Type="Int32" ControlID="ddlAccountSourceId" PropertyName="SelectedValue" /> 
    </FilterParameters> 
    <UpdateParameters> 
     <asp:Parameter /> 
     <asp:Parameter Name="ACCOUNT_SOURCE_ID" /> 
    </UpdateParameters> 
</asp:SqlDataSource> 
<asp:SqlDataSource ID="dsAccountSourceId" runat="server" ConnectionString="<%$ ConnectionStrings:ARC_REFERENCEConnectionString %>" 
    SelectCommand="SELECT DISTINCT [ACCOUNT_SOURCE_ID] as AccountId FROM [REF_BACHE_ACCOUNT]" 
    DataSourceMode="DataSet"></asp:SqlDataSource> 

回答

1

你傳遞一個值不是的Int32。

<asp:ListItem Text="All" Value="%"></asp:ListItem> 

刪除此行及其工作。爲了向他們展示你所需要的其他方式......