开发者

Listview DataPager with ObjectDataSource problem

开发者 https://www.devze.com 2023-01-03 21:46 出处:网络
I was added the DataPager Control i开发者_如何学Gonside Listview. There is no problem while displaying the data. But When I click the Next page button I m getting error.

I was added the DataPager Control i开发者_如何学Gonside Listview. There is no problem while displaying the data. But When I click the Next page button I m getting error.

Error: The Select operation is not supported by ObjectDataSource 'ObjectDataSource2' unless the SelectMethod is specified.

protected void Page_Load(object sender, EventArgs e)
        {

        if(!IsPostBack)      
        FillGrid();
        }

        private void FillGrid()
        {           
            User user = new User();
            user = (User)HttpContext.Current.Session["login"];
            ObjectDataSource2.SelectMethod = "GetDetails";
            ObjectDataSource2.SelectParameters.Add("Customer_ID", DbType.Int32, Convert.ToString(user.Customer_ID));
            ObjectDataSource2.SelectParameters.Add("Selected_Period", DbType.String, Convert.ToString(Request.QueryString["period"]));
            ObjectDataSource2.TypeName = "Online.Lib.Invoice";

        }

CodeBeside:

<asp:ListView ID="ListView1" runat="server" DataSourceID="ObjectDataSource2">
       <LayoutTemplate>            
                <asp:DataPager ID="DataPager1" PagedControlID="ListView1"   runat="server">
                <Fields> 
               <asp:NumericPagerField ButtonCount="10" />       
               <asp:NextPreviousPagerField FirstPageText="İlk" LastPageText="Son" NextPageText="İleri" PreviousPageText="Geri" />
              </Fields>
                </asp:DataPager>                                                  
            </LayoutTemplate>  
   </asp:ListView>


Ok. Your FillGrid() works well and you can load it's data by the Page_Load routine. When you click "Next page" of the ListView, you're doing a PostBack.

if(!IsPostBack)      
  FillGrid();
}

..Which means FillGrid() aren't loaded (which is the place ObjectDataSource have it's Select instruction). That's out of what I can see in the code snippets above. Quite common to make such mistakes in IsPostBack handling.

0

精彩评论

暂无评论...
验证码 换一张
取 消