This isn't really necessary. What you usually do is this: find the row which
is the currently selected in a control. You could use the Binding Manager to
find out the current
object/row that the bound datagrid is now referring to. For example, to get
the current row, use:
((CurrencyManager)BindingContext[datatablename]).Current.
Cast this into a datarow (or your typed one), and then use it.
Once you have the row, you could get the primary key or whatever field you
require.
Your method will work, but it not the .NET way of doing things
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.