Hot to not fech automatically LLBLGenProDataSource2 on asp

Posts   
 
    
wexa
User
Posts: 38
Joined: 27-Jul-2007
# Posted on: 27-Jul-2007 05:18:36   

I am using a datagrid to display data from a dataview on asp.

I am using LLBLGenProDataSource2 and I must assign the control to the datasource of the grid in order to get the columns, keyfields and all that info that my datacontrol needs.

My probblem is that I have many registers and the LLBLGenProDataSource2 is fetching automatically, I am using filters and a button so after the user enters some parameters is when I want to fetch the view.

So how do you do to dont fetch the LLBLGenProDataSource2 automatically, just until I call the FETCH.

Regards

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 27-Jul-2007 09:41:02   

Don't declaratively assign the LLBLGenProDataSource to the Grid's datasource. Do that in code in the appropriate event.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 27-Jul-2007 10:49:10   

Walaa wrote:

Don't declaratively assign the LLBLGenProDataSource to the Grid's datasource. Do that in code in the appropriate event.

That can be a little tricky. The thing is: during the page lifecycle (which is a mistery to many of us, including myself) the grid will be bound to its datasource and the datasource will then get a call from the grid to fetch data. If you bind the datasource after that, it might be that the things happening on the form aren't what you'd expect.

So you can also use the workaround to specify a filter which returns 0 rows (like where a field = 0 or 1=0).

This is a bit of a sad workaround, however as things are executed automatically by the asp.net framework, it's a bit cumbersome to switch things on and off at the right time, because your code might very well be executed after the call is already been made.

Frans Bouma | Lead developer LLBLGen Pro
wexa
User
Posts: 38
Joined: 27-Jul-2007
# Posted on: 27-Jul-2007 16:40:37   

Thank you for your help, what I did was to insert a select parameter in the designer that returns 0 values.

Then in my filter button I did cleared the select parameter and assigned the filter value.

Here is what I have on the Filter Button:

protected void btnSearch_Click(object sender, EventArgs e)
    {
        _positionSource.SelectParameters.Clear();
        _positionSource.FilterToUse = null;
        IRelationPredicateBucket bucket = new RelationPredicateBucket();
        if (areaDropDown.SelectedValue != null)
        {
            bucket.PredicateExpression.Add(vPositionsFields.ClaArea == Convert.ToInt32(areaDropDown.SelectedValue));
        }
        else
        { lblErrorSearch.Text = "Please select an area"; }
        _positionSource.FilterToUse = bucket;
    }