I’m creating a view where the model is List of Foo. I want to create a list with an actionlink to select a given Foo item and need to pass it back to the controller. However, there is nothing unique enough in Foo to tie to the actionlink. I’d like to pass the index of the item in Foo but don’t know how to get the index from the model inside of the view.
Is this possible to do this without creating a viewmodel that contains the index?
Do you mean
@for(int i=0; i<Model.Count; i++), then use i as the id? But you’ll need to make sure the positions won’t change.I think it will be better to have ids on Foo in the long term.