Gridview in edit mode, LLBLGenDataSource and FilterToUse

Posts   
 
    
kdekok
User
Posts: 26
Joined: 07-Apr-2008
# Posted on: 14-Apr-2008 15:26:55   

Still struggling with understanding the vast power of llblgen, i ran into something, which seems odd to me and gives me a headache frowning

Situation: GridView, LLBLGenDataSource (livepersistance=true) to an entitycollection named TUserCollection on the page also a Filterbutton and a textbox. The filterbutton_click action simply creates a new PredicateExpression based on the text entered in the textbox. And the gridview is automatically refreshed to the filtered data. So far so good.

Now when i click the row's Edit button, which will bring the gridviewrow into editmode, the filter seems to be discarded, the full dataset again is shown in the grid, and the ROWINDEX of the row i clicked the edit button on, is put into edit mode, which can be a total different row, when the filter is gone.

e.g.: Unfiltered grid:

  • normal user 1 (edit)
  • normal user 2 (edit)
  • test user 1 (edit)
  • test user 2 (edit) Filter on the word test: Code is something like:

DataSource.FilterToUse=new PredicateExpression(FieldCompareLike(UserNameField, "%test%"));

which shows filtered grid:

  • test user 1 (edit)
  • test user 2 (edit) Now i click edit on test user 1. The result is, the full grid is shown again en the row of normal user1 is into edit mode.

What to do!? confused confused confused

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 14-Apr-2008 19:39:36   

Could you reproduce your situation in a test solution preferably using Northwind so we can help you better?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 15-Apr-2008 09:51:42   

I can't reproduce it.

Frans Bouma | Lead developer LLBLGen Pro
kdekok
User
Posts: 26
Joined: 07-Apr-2008
# Posted on: 15-Apr-2008 09:59:07   

I discovered i couldn't reproduce the behaviour with a normal GridView either.

So i found out, the problem was in my overridden GridView.

The issue was this:



         protected override void OnRowCreated(GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState != DataControlRowState.Edit)
            {
                e.Row.Attributes["onclick"] = ((System.Web.UI.Page)(HttpContext.Current.Handler)).ClientScript.GetPostBackClientHyperlink(this, "Select$" + e.Row.RowIndex);
                e.Row.Style["cursor"] = "hand";
            }
            base.OnRowCreated(e);
        } 

The OnClick event for the entire row was messing up, and throwing in an extra page load when i clicked the edit button, which reset the datasource.

When this line was commented out, it worked fine, only now i have to figure out another way to have a select when clicked on the entire row without messing up disappointed