I've created a objectadasource that returns a datatable, the gridview
is binded to this datasource.
the ODS have parameters assigned on the Page_Load event, and the ODS returns the data ok and the gridview shows it fine.
the problem is
i have a textbox with a filter.
first I created a filterexpression in gridview, using the contents of
the textbox, worked fine for me.
but now I've enabled the paging in gridview.
then the filterexpression is not useful now, since the ODS returns
only the rows of the pagesize of gridview.
I did a new ODS method that select data from parameters page and pagesize according to GridView, and it's OK.
now my filter textbox passes his text property to a parameter of the ods
select method, then the ods gets the data based on my filter and shows
it in the grid.
on the Page_Load:
ObjectDataSource_Lista.SelectParameters["search"].DefaultValue = filter;
ObjectDataSource_Lista.SelectParameters["id"].DefaultValue = ID.ToString();
but when I change the value of the filter, the grid doesn't refresh.
on debugging. I see that the ODS Select Method is refreshed ok, but the GridView don't.
So I need to call mannually the Databind() method of the grid, to refresh data.
the problem is, I have a commandbutton on the grid, and if I manually
databind(), the command button stops functioning, generating Page ValidateRequest errors.
My question is: how to databind() the grid automatically after the datasource refreshed?
ps: on the ODS Selected event, causes a infinite loop and the debug webserver crashes.
Temporary solution: Created a Variable
private bool wasdatabound;
on the event GridView_Databound, set wasdatabound = true;
on the Page_PreRenderComplete,
if ((GridView1.Visible) && (!databounded)) GridView1.DataBind();