Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can Convert DataRow to DataRowView in c#

Can or how to convert DataRow to DataRowView?

For example:

   DataTable dt=ds.Tables[0];
   DataRow dr= dt.NewRow();           
   DataRowView drv = ???? 
like image 487
Ali Sarshogh Avatar asked Mar 26 '13 07:03

Ali Sarshogh


2 Answers

Use

DataTable dt=ds.Tables[0];
DataRow dr= dt.NewRow();         
DataRowView drv= dt.DefaultView[dt.Rows.IndexOf(dr)];
like image 171
BizApps Avatar answered Sep 19 '22 09:09

BizApps


Use. It also works if the DataGrid is ordered.

DataRowView selecRow = dataTable.DefaultView.Cast<DataRowView>().Where(a => a.Row == desRow).FirstOrDefault();
like image 32
Nayara Ferreira de Jesus Avatar answered Sep 21 '22 09:09

Nayara Ferreira de Jesus