Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why ObjectDataSource not sending correct parameter value?

Tags:

c#

asp.net

I have a ObjectDataSource in which I was trying to pass some parameters.

GridDataSource.SelectMethod = "GetAllCountries";
GridDataSource.SelectParameters.Add("PageSize", pageSize.ToString());
GridDataSource.SelectParameters.Add("OrderBy", orderBy);
GridDataSource.SelectParameters.Add("StartIndex", startIndex.ToString());

and my method is in App_Code/DAL/CountriesDB.CS

public  List<Countries> GetAllCountries(int PageSize,string OrderBy,int StartIndex)
{
..........
}

when I debugged it, in GetAllCountries Method PageSize=-1;OrderBy="",StartIndex=0 is passed...what is going on here??

thnx in advance...

like image 904
Tamal Kanti Dey Avatar asked Oct 06 '22 14:10

Tamal Kanti Dey


1 Answers

Handle the Selecting event of GridDataSource and enter your parameters there.

protected void GridDataSource_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
{    
    GridDataSource.SelectMethod = "GetAllCountries";            
    e.InputParameters.Clear();
    e.InputParameters.Add("PageSize", pageSize.ToString());
    e.InputParameters.Add("OrderBy", orderBy);
    e.InputParameters.Add("StartIndex", startIndex.ToString());         
}
like image 64
keyboardP Avatar answered Oct 09 '22 21:10

keyboardP