asp.net - VB.net Webform Gridview with checkbox DataControlRowType -
vb.net webform pulling data sql database gridview.
i have 2 bit columns rush , normal - in code behind if rush checked row cells turn red , normal turns blue.
the problem have bit true or false not having luck converting them integer or int32.
here code working with, code turn rows blue , if cell 7 not equal 1.
if go rush cell(10) error input string not in correct format.
question how convert bit true/false 1/0 or correct format.
protected sub onrowdatabound(sender object, e gridviewroweventargs) if e.row.rowtype = datacontrolrowtype.datarow dim sh string = convert.toint32(e.row.cells(7).text) each cell tablecell in e.row.cells if sh = 1 cell.backcolor = drawing.color.red else cell.backcolor = drawing.color.blue end if next end if end sub
why converting integer, when having bit column, try below code.
protected sub onrowdatabound(sender object, e gridviewroweventargs) if e.row.rowtype = datacontrolrowtype.datarow dim sh boolean = convert.toboolean(e.row.cells(7).text) each cell tablecell in e.row.cells if sh cell.backcolor = drawing.color.red else cell.backcolor = drawing.color.blue end if next end if end sub
Comments
Post a Comment