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...
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());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With