tags:

views:

7

answers:

1

I am using a nettiers generated EntityGridView, and I've added a method for OnSelectedIndexChanged. In that method, How do I get the currently selected entity from the EntityGridView?

A: 

Ok.. I got it. It was stupidly simple. Maybe not the best way, but I fooled around until I got the following code that worked, using the SelectedDataKey from the GridView and the EntityProvider to retrieve the entity data.

   public void GridView1_SelectedIndexChanged(Object sender, EventArgs e)
        {
            int idEntity = Int32.Parse( GridView1.SelectedDataKey.Value.ToString());
            s.Entities.MMEntity ent =
                 s.Data.DataRepository.MMEntityProvider.Get(
                        new s.Entities.MMrKey(idEntity)
                  );

       // use the entity here
    }
stephenbayer