From: 3P on
I would like to create a very simple form.

When client enters it he has a filter to set. Then push the button get the
data and display in GridView.
Grid uses ObjectDataSource and allows paging and sorting (using custom
stored proc returning only data needed on current page).
But seems that ObjectDataSource is refreshing data on every postback. It's
not ok because dropdowns in
filter also postback thus I hit the database and display data before
filter is set and before client
pushes the button. Plus it hits the database on first PageLoad.

Is there any way to prevent such a behaviour of ObjectDataSource? Or is
there a way to do it w/o ObjectDatasource?
Other then inheriting from GridView and overriding InitializePager (or sth
like that). I cannot find a way to tell
the grid how many records there is so it can generate the Pager.

I thought I found the solution by handling the Selecting event and
canceling it until user pushes the button. But when
there is data in grid and I cancel Selecting event the data in grid is
cleared :/

If it is not possible with ObjectDataSource, then I really don't know what
this control is for. Then it's totally unusable
for other then maybe one or two simplest solutions.


3P
From: Mr. Arnold on
3P wrote:
> I would like to create a very simple form.
>
> When client enters it he has a filter to set. Then push the button get
> the data and display in GridView.
> Grid uses ObjectDataSource and allows paging and sorting (using custom
> stored proc returning only data needed on current page).
> But seems that ObjectDataSource is refreshing data on every postback.
> It's not ok because dropdowns in
> filter also postback thus I hit the database and display data before
> filter is set and before client
> pushes the button. Plus it hits the database on first PageLoad.
>
> Is there any way to prevent such a behaviour of ObjectDataSource? Or is
> there a way to do it w/o ObjectDatasource?
> Other then inheriting from GridView and overriding InitializePager (or
> sth like that). I cannot find a way to tell
> the grid how many records there is so it can generate the Pager.
>
> I thought I found the solution by handling the Selecting event and
> canceling it until user pushes the button. But when
> there is data in grid and I cancel Selecting event the data in grid is
> cleared :/
>
> If it is not possible with ObjectDataSource, then I really don't know
> what this control is for. Then it's totally unusable
> for other then maybe one or two simplest solutions.
>
>

What are you talking about here? You don't want to go back to the database?
From: 3P on
Dnia 18-03-2010 o 23:09:51 Mr. Arnold <Arnold(a)arnold.com> napisa�(a):

> 3P wrote:
>> I would like to create a very simple form.
>> When client enters it he has a filter to set. Then push the button get
>> the data and display in GridView.
>> Grid uses ObjectDataSource and allows paging and sorting (using custom
>> stored proc returning only data needed on current page).
>> But seems that ObjectDataSource is refreshing data on every postback.
>> It's not ok because dropdowns in
>> filter also postback thus I hit the database and display data before
>> filter is set and before client
>> pushes the button. Plus it hits the database on first PageLoad.
>> Is there any way to prevent such a behaviour of ObjectDataSource? Or
>> is there a way to do it w/o ObjectDatasource?
>> Other then inheriting from GridView and overriding InitializePager (or
>> sth like that). I cannot find a way to tell
>> the grid how many records there is so it can generate the Pager.
>> I thought I found the solution by handling the Selecting event and
>> canceling it until user pushes the button. But when
>> there is data in grid and I cancel Selecting event the data in grid is
>> cleared :/
>> If it is not possible with ObjectDataSource, then I really don't know
>> what this control is for. Then it's totally unusable
>> for other then maybe one or two simplest solutions.
>>
>
> What are you talking about here? You don't want to go back to the
> database?

Only when client pushes GetMeData button. Not on every postback.
From: Mr. Arnold on
3P wrote:
> Dnia 18-03-2010 o 23:09:51 Mr. Arnold <Arnold(a)arnold.com> napisa�(a):
>
>> 3P wrote:
>>> I would like to create a very simple form.
>>> When client enters it he has a filter to set. Then push the button
>>> get the data and display in GridView.
>>> Grid uses ObjectDataSource and allows paging and sorting (using
>>> custom stored proc returning only data needed on current page).
>>> But seems that ObjectDataSource is refreshing data on every postback.
>>> It's not ok because dropdowns in
>>> filter also postback thus I hit the database and display data before
>>> filter is set and before client
>>> pushes the button. Plus it hits the database on first PageLoad.
>>> Is there any way to prevent such a behaviour of ObjectDataSource? Or
>>> is there a way to do it w/o ObjectDatasource?
>>> Other then inheriting from GridView and overriding InitializePager
>>> (or sth like that). I cannot find a way to tell
>>> the grid how many records there is so it can generate the Pager.
>>> I thought I found the solution by handling the Selecting event and
>>> canceling it until user pushes the button. But when
>>> there is data in grid and I cancel Selecting event the data in grid
>>> is cleared :/
>>> If it is not possible with ObjectDataSource, then I really don't
>>> know what this control is for. Then it's totally unusable
>>> for other then maybe one or two simplest solutions.
>>>
>>
>> What are you talking about here? You don't want to go back to the
>> database?
>
> Only when client pushes GetMeData button. Not on every postback.

Well, you need to change the binding source to do the binding in the
codebhind file on page_load it seems for the code.

If (!IsPostBack)
(
go get the data and bind it to the control, using a binding method
-- a first time load only -- if it's postback, then you don't do it.
}

This is not the control you're using a binding method of using a dataset
to bind to the control. But the principle is the same for any control
you're trying to bind the results of the SQL query to the control.

You have two choices of using a dataset to bind to the control or using
a collection to bind to a control by using a SQL datareader and
populating the collection of objects to bind to the collection to the
control.

http://demos.telerik.com/aspnet-ajax/treeview/examples/programming/databinding/defaultcs.aspx

You look at the example code for C# or VB and see how to do the binding
programmically. It may be easiest to use the dataset example.

Then in the button_click_event, you go read the data and bind it to the
control.

You have the control.
From: 3P on
Dnia 19-03-2010 o 01:51:23 Mr. Arnold <Arnold(a)arnold.com> napisa�(a):

> 3P wrote:
>> Dnia 18-03-2010 o 23:09:51 Mr. Arnold <Arnold(a)arnold.com> napisa�(a):
>>
>>> 3P wrote:
>>>> I would like to create a very simple form.
>>>> When client enters it he has a filter to set. Then push the button
>>>> get the data and display in GridView.
>>>> Grid uses ObjectDataSource and allows paging and sorting (using
>>>> custom stored proc returning only data needed on current page).
>>>> But seems that ObjectDataSource is refreshing data on every postback.
>>>> It's not ok because dropdowns in
>>>> filter also postback thus I hit the database and display data before
>>>> filter is set and before client
>>>> pushes the button. Plus it hits the database on first PageLoad.
>>>> Is there any way to prevent such a behaviour of ObjectDataSource? Or
>>>> is there a way to do it w/o ObjectDatasource?
>>>> Other then inheriting from GridView and overriding InitializePager
>>>> (or sth like that). I cannot find a way to tell
>>>> the grid how many records there is so it can generate the Pager.
>>>> I thought I found the solution by handling the Selecting event and
>>>> canceling it until user pushes the button. But when
>>>> there is data in grid and I cancel Selecting event the data in grid
>>>> is cleared :/
>>>> If it is not possible with ObjectDataSource, then I really don't
>>>> know what this control is for. Then it's totally unusable
>>>> for other then maybe one or two simplest solutions.
>>>>
>>>
>>> What are you talking about here? You don't want to go back to the
>>> database?
>> Only when client pushes GetMeData button. Not on every postback.
>
> Well, you need to change the binding source to do the binding in the
> codebhind file on page_load it seems for the code.
>
> If (!IsPostBack)
> (
> go get the data and bind it to the control, using a binding method
> -- a first time load only -- if it's postback, then you don't do it.
> }
>
Yeah this code works when I want to do it on button click. LOL.

I feel that You think that I don't anything about programming. But still
give me responses that have nothing to do with my problem.

That IsPostback is good for binding at the PageLoad not the button click.

And the question was if I can stop ObjectDatasource refresh data on every
postback.
I know I can do it in my button.click eventhandler on my own. But then I
have to write
code for paging, sorting etc.

Read the question before You asnwer please.