I am trying to loop through all rows on my GridView1 and change the backgournd colour of the rows as they are processed.
The loop works perfectly, but for some reason the line of code to set the Back Color is not being honoured.
nextRow.BackColor = System.Drawing.Color.RoyalBlue
Here is the complete loop.
For i As Integer = 0 To GridView1.Rows.Count - 1
Dim counter As Integer = GridView1.SelectedIndex + 1
Dim nextRow As GridViewRow
nextRow = GridView1.Rows(0)
If counter = GridView1.Rows.Count Then
nextRow = GridView1.Rows(0)
Else
'formatting
nextRow.BackColor = System.Drawing.Color.RoyalBlue
nextRow = GridView1.Rows(counter)
CompileHTML(GridView1.Rows(i))
ExportHTML(GridView1.Rows(i))
End If
Next
Your are setting the value of nextRow to the first row directly above the if statement so nextRow is always GridView1.Rows(0) when backcolor is set.
For Each row As GridViewRow In GridView1.Rows
row.BackColor = System.Drawing.Color.RoyalBlue
Next
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.