By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,865 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,865 IT Pros & Developers. It's quick & easy.

find the DataRow associated with datagrid row

P: n/a
Hi,

Is there better way to find the DataRow associate with row of a datagrid?

Now I put ID column(PK) as a column in a datagrid, and get this cell value
of the datagrid current row (DataGrid.CurrentRowIndex), then use
DataTable.Rows.Find(id) to find the datarow.

I feel this way is not generic. Is there better way to find the associated
DataRow?

System internally must know how they are associated, since I can edit the
datatable value in datagrid.

Thanks!
Ryan
Feb 12 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

"Ryan Liu" <ad********@online.sh.cn> wrote in message
news:%2***************@TK2MSFTNGP14.phx.gbl...
Hi,

Is there better way to find the DataRow associate with row of a datagrid?

Now I put ID column(PK) as a column in a datagrid, and get this cell value
of the datagrid current row (DataGrid.CurrentRowIndex), then use
DataTable.Rows.Find(id) to find the datarow.

I feel this way is not generic. Is there better way to find the associated
DataRow?
Maybe this is what you want:

DataRowView currentRowView =
(DataRowView)BindingContext[dataGrid1.DataSource,
dataGrid1.DataMember].Current;
DataRow currentRow = currentRowView.Row;

HTH,
Greetings


System internally must know how they are associated, since I can edit the
datatable value in datagrid.

Thanks!
Ryan

Feb 12 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.