How to update multiple rows in datatable based in particular value without using foreach loop

Hello everyone,

Consider in below screeshot i want to update all the rows column2 corresponding “text” value in Column1. I want to achieve it without using for each loop and SQL. I have to found few threads in forum now proper solution is given in that. Can someone help on it?

1 Like

@lakshman Can you help on this?

1 Like

@Manjuts90

Give me some time and am already trying this one.

5 Likes

@Manjuts90

Sorry. I tried so many ways but not finding required solution. I don’t know how to do this without using For Each loop.

5 Likes

@lakshman Thanks for your time, is it possible to get all indexes of particular element in colulm1 at once?

3 Likes

@Manjuts90

I didn’t not get. Could you please show me some sample input and output.

5 Likes

@lakshman In above screenshot,I want to get indexes of “text” data which 0,2,3 as output since text is present in those rows.

If I give input as “Form” I want to get indexes as 1,4.

Like wise if I give input as “Submit” I want to get index as 5.

I have to get this indexes without using for each loop. Can you get me solution for this.

1 Like

@Manish_Pandey By using add data row we can only new data to datatable. Your answer will not give solution to my question. Anyhow thanks for reply.

1 Like

@Manjuts90

Try this expression:

yourDT.AsEnumerable().Where(Function(row) row(“Column1”).ToString.Equals(“text”)).Select(Function(row) DT.Rows.IndexOf(row)).ToArray()

this will expression will give index of all matching rows and output is array of integer. If you have any doubts then let me know.

5 Likes

@lakshman Thanks for your time, query given by you is working perfectly.:slightly_smiling_face:

3 Likes

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