I have ObjectDataSourcewith settings SelectMethodand SelectParameters. The data source is tied to a grid view that successfully displays page load data.
I need the ability to re-run a method Selectdefined ObjectDataSourcethat will be stored in a variable and manipulate the elements in it. The problem I am facing is that the method call .Select()always returns 0 rows, despite the fact that it fills the grid correctly.
Is there a reason why I cannot manually restart the method Select()in the object's data source?
Update 2:
This is how I configure ObjectDataSource:
myObjectDataSource.TypeName = typeof(MyDataAccessObject).ToString();
myObjectDataSource.SelectMethod = "GetBy" + stringVariable;
myObjectDataSource.SelectCountMethod = "GetCountBy" + stringVariable;
myObjectDataSource.EnablePaging = true;
Update 1:
Select() OnClick event:
protected void LinkButton1_Click(object sender, EventArgs e)
{
SetupDataSource();
var items = objSource.Select();
int count = items.Count();
}
ObjectDataSource ( SelectMethod SelectParameters ) Page_Load.
ObjectDataSource :
<asp:ObjectDataSource ID="objSource" runat="server" EnablePaging="True" SortParameterName="sortExpression" ></asp:ObjectDataSource>
GridView :
<asp:GridView
ID="myGridView"
runat="server"
DataSourceID="objSource"
AllowPaging="true"
ShowHeader="true"
AutoGenerateColumns="false"
AllowSorting="true"
Width="100%" >