0

I would like to add one more query to this.. How Can Convert DataRow to DataRowView in c#

DataRowView drv= dt.DefaultView[dt.Rows.IndexOf(dr)];

This is the code which is mentioned there..

Assume a scenario, that a column has sorted and if i try to get the row view based on the row index, it will mismatch..

How could overcome this?

Community
  • 1
  • 1
Sankarann
  • 2,625
  • 4
  • 22
  • 59

1 Answers1

0

We could use the FindRows method to get the matched rows..

DataRowView drv = dt.DefaultView.FindRows(dr[Regex.Match(dt.DefaultView.Sort, @"\[([^)]*)\]").Groups[1].Value])[0];

In my case, i could take the first value of RowView collection. This is a kind of filtering the dataview with the respective value... and it solves my problem...

Sankarann
  • 2,625
  • 4
  • 22
  • 59