Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I used DataPager , ListView and DataPager to display my data , everything(emphatically paging) was OK .I also changed the select method of objectDataSource this way:

HTML
ObjectDataSource1.SelectMethod= "GetPruductByCondition";        
ObjectDataSource1.SelectParameters.Clear();
ObjectDataSource1.SelectParameters.Add("dropDownListValue", condition);
ObjectDataSource1.SelectParameters.Add("searchItem", searchItem);

it was OK too. But when i click on another page of DataPager , error below is displayed:

"ObjectDataSource 'ObjectDataSource1' could not find a non-generic method
'GetProductList'
that has parameters: dropDownListValue, searchItem."

how can I solve it?
(here is objectDatasource :
ASP.NET
<asp:ObjectDataSource ID="ObjectDataSource1" OldValuesParameterFormatString="original_{0}" SelectMethod="GetProductList" ...>
)

as a matter of fact I need to implement searching, and when the SearchButton is clicked the default SelectMethod of ObjectDataSource1 should be changed;for the first time the button is clicked my implementation works but I can not use DataPager to see other search results .
Posted
Updated 27-Jan-14 4:02am
v2

1 solution

This usually occurs when there is a Method Name or Parameter Name mismatch .

Here its due to the ObjectDataSource checks for the Method which is set in the Markup when there is a Rebind/Postback. Usually this happens when PageIndexChanged event fires due to the Pagination of the DataPager Control or even when the DropdownSelectedchange happens. Try to Debug and check which Select Method is getting called there?( GetPruductByCondition or GetProductList) and supply those parameters according to the select methods.
 
Share this answer
 
Comments
sepehr shamsaei 27-Jan-14 9:46am    
@JoCodes for the first page of DataPager `GetProductByCondition` is called but for the second, third,... `GetProductList` is being called which is not one I expect. what is your solution? also `GetProductByCondition` should work as search method and there is button to change SelectMethod of ObjectDataSource
JoCodes 27-Jan-14 22:16pm    
on pageindexchanged event the DataPager usually takes the method which is in the Markup property of the DataPager. I would suggest to assign both method on code behind only ( dynamically) and handle it in Postbacking events including the PageIndexchanged.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900