Gridview simple code exemple

Posts   
 
    
betux
User
Posts: 7
Joined: 22-May-2006
# Posted on: 22-May-2006 19:20:53   

Hello,

I'm discovering llblgen and i try to bind a gridview, edit it, and update.

I'have one entity (just for try before buy it).

i'have understand how work llbl but i'don't find simple code for visual in c#.

the exemple given in the demo is too hard for me.

for exemple i don't understand if i need to use DataAccessAdapter or collection.

lost in translation ... simple_smile

thanks.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 23-May-2006 03:07:51   
using (DataAccessAdapter adapter = new DataAccessAdapter())
        {
            EntityCollection collection = new EntityCollection(new TestEntityFactory());
            IRelationPredicateBucket filter = new RelationPredicateBucket();
            filter.PredicateExpression.Add(TestFields.TestId == 4); // This will filter the results to entities with their TestIds set to 4
            adapter.FetchEntityCollection(collection, filter);
            GridView1.DataSource = collection;
            GridView1.DataBind();
        }

Try to adapt this to your instance. If you have difficulties with making this work take a look at the manual for descriptions of how to work with the generated code. If you can't find your answer searching through these forums then post any problems you may be having with the code on here. Good luck.

betux
User
Posts: 7
Joined: 22-May-2006
# Posted on: 23-May-2006 13:37:58   

Whaou !! thanks !!

I'm understanding now that i'm working in selfservicing flushed

I creat an objectdatasource and i write to select one entity:

public static AppliCollection SelectAppli() { AppliCollection Applis = new AppliCollection(); Applis.GetMulti(null); return Applis; }

For the delete :

public void DeleteAppli(AppliEntity p) { p.Delete(); }

For update :

public static void UpdateAppli(AppliEntity p) { p.IsNew = false; p.IsDirty=true; p.Save();

}

some questions i have :

  1. i'm right ?? disappointed

  2. If i link directly my gridview to my collectionclassesapplicollection i can have directly getmultiasdatatable.

it work to view rows of my entity.

But i can't find update and delete always a problem interface ...

Someone can help me ? where i can find documentation ? i don't understand why everybody write code if we can access directly the object.

lost again in translation ... wink

thanks

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 24-May-2006 00:24:43   

hiya, if you speak french or spanish i might be able to translate....

Anyway, It is even easier than you think.But the only real way to learn is to have a look at the examples.

If you delete or add items to en entityCollection, it ALREADY KNOWS what items are dirty..all you have to do is call the "SaveMulti" method on the entityCollection.

If you want to DELETE a row from a datagrid you can do the following, using a unitOfWork:


 private void dgvReturns_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            TblReturnProductsEntity currReturn = (TblReturnProductsEntity)e.Row.DataBoundItem;
            UnitOfWork uow = new UnitOfWork();
            uow.AddForDelete(currReturn);
            uow.Commit(new Transaction(IsolationLevel.ReadCommitted, "UOW"), true);
                    }

The help manual is also a good place to look.

cheers,

yogi