Initialize global list of {string, number} pairs
main = {{"apple", 1}, {"banana", 2}, {"carrot", 3},{"donut", 4}
Function to edit item number j from the list
EditItem[j_] := Module[{tx, nm},
  tx = main[[j]][[1]];
  nm = main[[j]][[2]];
  CreateDialog[{
    Panel[
     Column[{
       InputField[Dynamic[tx], String],
       InputField[Dynamic[nm], Number],
       Row[{
         CancelButton[],
         DefaultButton[
          "Save",
          main[[j]][[1]] = tx;
          main[[j]][[2]] = nm;
          DialogReturn[]
          ]
         }]
       }]
     ]
    }, Modal -> True]
  ]
If I call the edit function directly, it works fine.
EditItem[4]
NotebookObject[FrontEndObject[LinkObject["tp8_shm", 3, 1]], 110]
main
{{"apple", 1}, {"banana", 2}, {"carrot", 3}, {"dingbat", 5}}
If I call the edit function from the buttons in this dynamic table, it doesn't work. The fields are not pre-populated and the assignments fail.
In[11]:= Dynamic[
 Panel[
  Grid[
   Table[{Button[main[[j]][[1]], EditItem[j]], main[[j]][[2]]}, {j, 1, Length[main]}]
   ]
  ]
 ]
Why doesn't the function call work from inside the buttons?