aligning datagrid with datasource

J

Jan Limpens

hi folks,

which is the best way to get to the datasource/row via a bound datagrid?

my datagrid is bound to a dataview.
when i select a button in the grid i want easy access to the
corresponding datarowview in the dataview.

until now my best bet is to get the datakey from the
datagrid.SelectedItem, sort my view by the key´s field and then use
dataview.Find() to get the row. but thats horribly cubersome and sorts
my view in a way i do not like it to be sorted!

i am very sure there must be a much better method which i haven't found
yet - please tell me :)

thanks
jj
 
L

Luca Bertoldi

Hi Jan,
it seems you need to use the
System.Web.UI.WebControls.DataGridCommandEventArgs parameter passed to the
event handler: it has an Item property which in turn has a DataItem property
that references the DataRowView you need to access.

Hope it helps,
Luca
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top