How to read Rows of a DatagridView through for loop

Tags:
DataGridView
VB.NET 2008
Visual Studio 2008
Hi, My application is in VS2008 coded in Vb.net.I have a datagridview which is populated from Database.I have a save button on the same form that has DatagridView. My requirement is i want that all the records that are populated in DatagridView should be saved in a certain table of the database when the user clicks save. Im done with my save and Update code.What im not able to do is,im not able to increment the counter and move to the next row of datagridView when my For loop is executing after the click of Save button. Below is my Code.
For i As Integer = 0 To DGVStudRecord.RowCount - 1
My code to Update And Save
Next
Here what is happening is when save button is clicked my for Loop is executing and looping till RowCount-1.But i want that after completion of each loop my i should get to the next row in the datagirdView.I should be able to get the values of next row to pass it to my controls that are carrying update and delete operation. The entire data in the datagridview will be saved in a certain table at the click of save button. Please suggest.


Software/Hardware used:
VS2008,vb.net

Answer Wiki

Thanks. We'll let you know when a new response is added.

You don’t need to modify your Loop, but your code to update and save.

Your ‘save’ code should use ‘i’ as the row number.

For example, to reference the first column of the current row, you would use something like this:

<pre>DGVStudRecord.Rows(i).Cells(0).Text</pre>

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following