Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

parse through each row of a datagrid

Posted on 2006-04-19
8
Medium Priority
?
237 Views
Last Modified: 2008-02-01
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.
0
Comment
Question by:Term56
8 Comments
 
LVL 23

Expert Comment

by:naveenkohli
ID: 16489050
You can use DataGrid.Items to enumerate over each item in the grid.
0
 
LVL 5

Expert Comment

by:mirmansoor
ID: 16489777
i think you can do something like this:

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

HTH...
0
 
LVL 25

Accepted Solution

by:
DBAduck - Ben Miller earned 2000 total points
ID: 16493414
Dim dgItem as DataGridItem

For Each dgItem in DataGrid1.Items

Next
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Term56
ID: 16501534
that worked, but how do I actually go through the items, this doesnt seem to be working :

dgItem.Cells(0).Text
0
 

Author Comment

by:Term56
ID: 16501539
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
 
LVL 25

Expert Comment

by:DBAduck - Ben Miller
ID: 16501662
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
 

Author Comment

by:Term56
ID: 16506315
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
 
LVL 25

Expert Comment

by:DBAduck - Ben Miller
ID: 16510242
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question