I use the trick of creating the client-side function call in ASP.NET in the
ItemDataBound event for each row of a grid, and passing the ID of the
control to the function so it can be located in the client-side script.
You'll have to include the grid control ID as well as the textbox control ID
in the correct combination ("parentID_textboxID").
There's a heap of samples at:
http://www.daveandal.net/books/6744/samples.aspx
that do similar stuff. The Using a Client-side Confirmation Dialog one binds
a client-side event to every button in a Datagrid, and the various User
Control and Server Control examples do the same kind of thing with a number
of parameters passed to the client-side code to locate controls in the page
in the client-side code. You can download all the samples from:
http://www.daveandal.net/books/6744/