Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining the end of a datagrid

Status
Not open for further replies.

richself

Technical User
Jun 27, 2005
37
US
I am displaying the contents of a DataGrid into a label.

Below is what I have so far and it works if the number of rows don't go over 4.

Do Until count > 4
shiftString = CType(DsReport1.Tables("Report").Rows(count).Item("Shift"), String)
equipmentString = CType(DsReport1.Tables("Report").Rows(count).Item("Equipment"), String)
downtimeString = CType(DsReport1.Tables("Report").Rows(count).Item("Downtime"), String)

displayString += shiftString & " " & equipmentString & " " & downtimeString & ControlChars.NewLine

count += 1
Loop

displayLabel.Text = displayString

I need to determine what to use for my index of my loop. I just pulled 4 out of the air. One time it might be 10 or 2 for that matter. What it comes down to I guess, is how to determine the number of rows in the DataGrid?

Thanks
 
Use the Datarow collection of the Datatable to scan through each record in your Table.
Code:
        For Each r As DataRow In dsReport1.Tables("Report").Rows
            shiftString = r("Shift").ToString
            equipmentstring = r("equipment").ToString
            downtimestring = r("downtime").ToString
            displaystring += shiftstring & " " & equipmentstring & downtimestring
        Next


Sweep
...if it works dont f*** with it
curse.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top