parse through each row of a datagrid

Just need the code to take a datagrid, and loop through each row

Is it something like For Each Row in MyDataGrid.Rows ? I know that's wrong but was thinking it would be something like that.
Term56Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

naveenkohliCommented:
You can use DataGrid.Items to enumerate over each item in the grid.
0
mirmansoorCommented:
i think you can do something like this:

Dim dr As DataRow
For Each dr In DataGrid1.Rows
'your code                
Next

HTH...
0
DBAduck - Ben MillerPrincipal ConsultantCommented:
Dim dgItem as DataGridItem

For Each dgItem in DataGrid1.Items

Next
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Term56Author Commented:
that worked, but how do I actually go through the items, this doesnt seem to be working :

dgItem.Cells(0).Text
0
Term56Author Commented:
and is there a way to look at the cells based on the name rather than the 0...Want to do that for dynamic and scalability.
0
DBAduck - Ben MillerPrincipal ConsultantCommented:
Well, the only way that the dgItem.Cells(0).Text will work is if it is bound yet, or has predefined columns when you access them.

And there is no Name for a Cell, as it is a collection of items (TableCell) so any property of a TableCell is what you can get to.

the syntax above is VB and C# would just be Cells[0] instead.

Ben.
0
Term56Author Commented:
hi dbaduck, yes, the datagrid is already bound to a dataset.

But for some reason when I try to click a button to do something in the datagrid, (after it is already bound), I am not seeing anything. I am using custom columns but they are defined and showing up well.

any other ideas ?
0
DBAduck - Ben MillerPrincipal ConsultantCommented:
Well, it may depend on where you are calling it as well.

Is this in an event of a click like you illustrated above?  Show us some code as to where you access the datagrid in enumeration so that we can get a better idea of how to help you.  I know that this is the way to do it, because I have done it, but want to make sure that I have the info I need to fully resolve this.

Ben.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.