Click here to Skip to main content
14,303,229 members
Rate this:
Please Sign up or sign in to vote.
See more:
hi,
i use this code to loop in gridview and insert the rows data into MySQL DB ,

 for (int ItemIndex = 0; ItemIndex < gridView1.DataRowCount; ++ItemIndex)
                {

}


but the last row didn't saved!

What I have tried:

i tried to use Foreach but i think Devexpress use only this syntax to iterate through all rows
Posted
Updated 26-Jul-19 20:54pm
Comments
Richard MacCutchan 26-Jul-19 11:18am
   
Some part of the code that you have not not shown us is probably not working.
Rate this:
Please Sign up or sign in to vote.

Solution 1

You could try Data Binding, if your MySQL driver allows it, see answers here: How load Mysql table to DATAGRIDVIEW of C#[^]

For more advanced purposes read: A Detailed Data Binding Tutorial[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Set a breakpoint in your loop and check the values of ItemIndex.
I expect that you will see that all your gridview rows are being addressed and your problem is in your code which you didn't show (as already suspected by Richard MacCutchan).
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100