Question

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?

Was it helpful?

Solution

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
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top