public SqlDataReader GetBooks(string SortColumnExpression,int startRowIndex, int maximumRows )
{
  //代码省略,这样没有一点问题存在 ,GetAllBooksCount省略
}
//现在想加个额外的参数
public SqlDataReader GetBooks(string SortColumnExpression,int startRowIndex, int maximumRows,string SqlWhere )
{
  //代码省略,加个额外的参数就出错了
}
protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{
    e.InputParameters.Add("SqlWhere", TextBox1.Text);
}[code=C#][
//前台代码
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
    AllowSorting="True" DataSourceID="ObjectDataSource1" PageSize="5">
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
    SelectMethod="GetBooks"
    EnablePaging="true"
    SelectCountMethod="GetAllBooksCount"
    SortParameterName="SortColumnExpression"
     TypeName="_2008NetControl.Class.SortAndPager" 
    onselecting="ObjectDataSource1_Selecting">
</asp:ObjectDataSource>
<br />
</div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
/code]
请问大家这个参数该怎们加
开发工具VS2008,还有一个是ObjectDataSource的错误好难找,页面一刷新就没看见错误了

解决方案 »

  1.   


    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" DataSourceID="ObjectDataSource1" PageSize="5">
    </asp:GridView>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
        SelectMethod="GetBooks"
        EnablePaging="true"
        SelectCountMethod="GetAllBooksCount"
        SortParameterName="SortColumnExpression"
         TypeName="_2008NetControl.Class.SortAndPager" 
        onselecting="ObjectDataSource1_Selecting">
    </asp:ObjectDataSource>
    <br />
    </div>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>//如果添加个查询参数也不行
      <SelectParameters>
                        <asp:ControlParameter ControlID="TextBox1" Name="SqlWhere" PropertyName="Text" 
                    Type="String" />
                </SelectParameters>