How to swap the data between the cells

Hi All,

I have data in two column like name1 and name2 the condition is that if we have data available


in name2 column then we have to swap the data between to cells.

Please guide me how to do.

@K_Anbarasu,

Use this LINQ in Invoke Code:

dataTable.AsEnumerable(). _
    Where(Function(row) Not String.IsNullOrEmpty(row.Field(Of String)("name2"))). _
    ToList(). _
    ForEach(Sub(row)
                Dim temp As String = row.Field(Of String)("name1")
                row.SetField("name1", row.Field(Of String)("name2"))
                row.SetField("name2", temp)
            End Sub)

Pass argument to Invoke code like this:

Before:

After:

Sample XAML:

Main.xaml (9.6 KB)

Thanks for your support

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.