asp.net - VB.net For Each Loop Not Accounting for First Datarow -
i looping through data gridview in visual studio, loop works , code pretty want,
my problem seems skip, or not account first row in gridview, have looked online resolve cannot find anything,
i wondering if assistance this...
here code loop:
'checks flags montor/expiry date set red or green cells '------------------------------------------------------------------ each row gridviewrow in gridview3.rows '----------------------------------------------------------------------------------------- dim monitorval string = gridview3.datakeys(e.row.rowindex).values("monitor").tostring if monitorval.contains("yes") dim isextention string = gridview3.datakeys(e.row.rowindex).values("filename").tostring if isextention = "" or isextention = nothing or isextention = "null" 'set red '-------- e.row.backcolor = drawing.color.lightpink else 'else green '----------- e.row.backcolor = drawing.color.lightgreen end if else 'else green '----------- e.row.backcolor = drawing.color.lightgreen end if next
i guess "first row in gridview" means header-row of grid. not returned gridview.rows
, rows datacontrolrowtype.datarow
returned. can in events rowdatabound
or rowcreated
. suggest use rowdatabound
in case:
protected sub gridview3_rowdatabound(sender object, e gridviewroweventargs) handles gridview3.rowdatabound select case e.row.rowtype case datacontrolrowtype.header ' ... ' case datacontrolrowtype.datarow ' ... ' case datacontrolrowtype.footer ' ... ' end select end sub
only rows
rowtype
property setdatacontrolrowtype.datarow
stored inrows
collection. gridviewrow objects represent header, footer, , pager rows not included in collection.
Comments
Post a Comment