From: Mr. Arnold on
3P wrote:
> 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 see that you have blinders on and can only see black or white. There
are no other colors that you see, huh?

>
> 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.

You are wrong. It's a one time bind of data to the control on the page
load, and it doesn't bind anymore on the postback. Or don't you
understand that? Don't you understand to load the control at page_Load
on postback and first time load of the control with data.

And if you tell me that the control can only be loaded on user clicking
a button at application start, then it's ridiculous and totally unuser
friendly.

>
> And the question was if I can stop ObjectDatasource refresh data on
> every postback.

How are you going to tell a OBJECTDATASOURCE that you bound at the
ASP.aspx to NOT go back to the database on a POSTBACK? YOU CAN'T DO IT!

You had better come-up with something else, flip the script, as there is
no magic bullet in sight for you.

> 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.

You find that magic bullet you're not going to find, please.

Your compression to think outside the box and take another path is
suspect, and you need to flip the script if you can.
From: Mr. Arnold on
3P wrote:

<snipped>

One other thing, there is a magic bullet for you where you take complete
control of the datasource and how it gets data.

But that would require you to 'think outside the box' and figure out
this. How can I tell the datasource to not give me back the data, since
I am the one programming it and give it back when I tell it to give it
back. Can I pass a parm to it?

<copied>

Note that these methods are completely customizable and provides the
platform for adding custom business logic,
which was always missing earlier while binding the UI Layer directly
using SQL DataSource, LINQ DataSource etc.

<end copy>

This applies to VS 2008 too.

<http://geekswithblogs.net/ranganh/archive/2009/12/14/using-wcf-ria-services-without-silverlight-in-visual-studio-2010.aspx>
<http://msdn.microsoft.com/en-us/library/ee707344(VS.91).aspx>

You don't need physical n-tier separation to do it, but rater logical
n-tier separation on the same Web server.

I know what you're talking about. But do you know what I am talking about?

From: 3P on
Dnia 19-03-2010 o 19:32:15 Mr. Arnold <Arnold(a)arnold.com> napisa�(a):

> 3P wrote:
>> 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 see that you have blinders on and can only see black or white. There
> are no other colors that you see, huh?
>
>> 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.
>
> You are wrong. It's a one time bind of data to the control on the page
> load, and it doesn't bind anymore on the postback. Or don't you
> understand that? Don't you understand to load the control at page_Load
> on postback and first time load of the control with data.
>
And where do You do one time bind of data if not in PageLoad?

How if (!IsPostback) is used in Button.Click? Please show.

> And if you tell me that the control can only be loaded on user clicking
> a button at application start, then it's ridiculous and totally unuser
> friendly.
>
What? That was very simple. Setup filter then presh show me the data.
Then setup new filter and press show me the data again.
What is "unuser friendly"? (whatever that means).


>> And the question was if I can stop ObjectDatasource refresh data on
>> every postback.
>
> How are you going to tell a OBJECTDATASOURCE that you bound at the
> ASP.aspx to NOT go back to the database on a POSTBACK? YOU CAN'T DO IT!

I can handle Selecting event and set e.Cancel = true; and it doesn't hit
the database

Nevermind now. The only way to do it is inherit from GridView control and
override
InitializePager. Then I can do

btn_Click(...)
{
grid.NumberOfRows = sth;
grid.Datasource = ds;
grid.DataBind();
}

grid doesn't provide "NumberOfRows" property so You have to inherit from
it to add it.
From: Mr. Arnold on
3P wrote:
> Dnia 19-03-2010 o 19:32:15 Mr. Arnold <Arnold(a)arnold.com> napisa�(a):
>
>> 3P wrote:
>>> 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 see that you have blinders on and can only see black or white. There
>> are no other colors that you see, huh?
>>
>>> 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.
>>
>> You are wrong. It's a one time bind of data to the control on the page
>> load, and it doesn't bind anymore on the postback. Or don't you
>> understand that? Don't you understand to load the control at
>> page_Load on postback and first time load of the control with data.
>>
> And where do You do one time bind of data if not in PageLoad?
>
> How if (!IsPostback) is used in Button.Click? Please show.

The !IsPostback is about loading the control the very first time the
page is loaded with the control loaded and page rendered. You could have
passed some kind of initial filter to the dataload and loaded the
control out the gate.

There is nothing worst than a page coming up the first time the page is
loaded and a control such as a gridview is blank. And then I the user
must set a filter and load it the first time with a button?

The ispostback has NOTHING to do with your button-click. But it's a way
of making the page more user friendly so the user doesn't have to do
some ridiculous button-click to initially load the control. It should
already be loaded initially.

>
>> And if you tell me that the control can only be loaded on user
>> clicking a button at application start, then it's ridiculous and
>> totally unuser friendly.
>>
> What? That was very simple. Setup filter then presh show me the data.
> Then setup new filter and press show me the data again.
> What is "unuser friendly"? (whatever that means).

It's ridiculous, and if I were the end-user or quality tester, it would
certainly hit the trash can as unnecessary functionality. The control
should have been initially loaded with data.

>
>
>>> And the question was if I can stop ObjectDatasource refresh data on
>>> every postback.
>>
>> How are you going to tell a OBJECTDATASOURCE that you bound at the
>> ASP.aspx to NOT go back to the database on a POSTBACK? YOU CAN'T DO IT!
>
> I can handle Selecting event and set e.Cancel = true; and it doesn't hit
> the database

Why would you be selecting a row, and the selection of the row causes it
to go back to the database? It seems to me that event needs to be disabled.

>
> Nevermind now. The only way to do it is inherit from GridView control
> and override
> InitializePager. Then I can do
>
> btn_Click(...)
> {
> grid.NumberOfRows = sth;
> grid.Datasource = ds;
> grid.DataBind();
> }
>
> grid doesn't provide "NumberOfRows" property so You have to inherit from
> it to add it.

Not to be smart here, I wouldn't waste my time on it, and I would take
control of the paging myself using a algorithm and using
PageIndexedChanged event to control paging. Or on NeededDataSource and
control paging there. I don't know if .Net controls have the event, like
RadCcontrols.
From: 3P on
>> And where do You do one time bind of data if not in PageLoad?
>> How if (!IsPostback) is used in Button.Click? Please show.
>
> The !IsPostback is about loading the control the very first time the
> page is loaded with the control loaded and page rendered. You could have
> passed some kind of initial filter to the dataload and loaded the
> control out the gate.

And I said about loding it at the button click not at the PageLoad right?
>
> There is nothing worst than a page coming up the first time the page is
> loaded and a control such as a gridview is blank. And then I the user
> must set a filter and load it the first time with a button?

Total nonsense. Database contains hundreds of tousands or records. Why
waste
users time, hit the database, and show him the data that he doesn't want?
And did You think for a second that this may be what user required?
Showing data after button click?

>
> The ispostback has NOTHING to do with your button-click. But it's a way
> of making the page more user friendly so the user doesn't have to do
> some ridiculous button-click to initially load the control. It should
> already be loaded initially.
Yeah run some SQL on 1 mil records and display without any filter. User
has to wait
for page to load and then still has to set the filter to se the data that
he's interested in.

>
>>
>>> And if you tell me that the control can only be loaded on user
>>> clicking a button at application start, then it's ridiculous and
>>> totally unuser friendly.
What application start? Do You understand english at all? Have You seen
any form
containing filter on top of it and then grid showing data filtered with
this filter?

>>>
>> What? That was very simple. Setup filter then presh show me the data.
>> Then setup new filter and press show me the data again.
>> What is "unuser friendly"? (whatever that means).
>
> It's ridiculous, and if I were the end-user or quality tester, it would
> certainly hit the trash can as unnecessary functionality. The control
> should have been initially loaded with data.
And if I were I would ask why this page loads so slow and why does it show
me data
I dont give a f... about. And I would ask why the hell did You make it
show data
when I told you to do it on button click.

>
>>
>>>> And the question was if I can stop ObjectDatasource refresh data on
>>>> every postback.
>>>
>>> How are you going to tell a OBJECTDATASOURCE that you bound at the
>>> ASP.aspx to NOT go back to the database on a POSTBACK? YOU CAN'T DO IT!
>> I can handle Selecting event and set e.Cancel = true; and it doesn't
>> hit the database
>
> Why would you be selecting a row, and the selection of the row causes it
> to go back to the database? It seems to me that event needs to be
> disabled.

Who is talking about selecting a row!? And where? You clearly have no idea
what You talking about.

>> Nevermind now. The only way to do it is inherit from GridView control
>> and override
>> InitializePager. Then I can do
>> btn_Click(...)
>> {
>> grid.NumberOfRows = sth;
>> grid.Datasource = ds;
>> grid.DataBind();
>> }
>> grid doesn't provide "NumberOfRows" property so You have to inherit
>> from it to add it.
>
> Not to be smart here, I wouldn't waste my time on it, and I would take
> control of the paging myself using a algorithm and using
> PageIndexedChanged event to control paging. Or on NeededDataSource and
> control paging there. I don't know if .Net controls have the event, like
> RadCcontrols.

Yeah and write Your custom grid from scratch and pager control. There is
no way
to tell the grid how many pages to display in pager other then using
ObjectDataSource
or by inheriting from GridView.