我想问在datagrid中,如何实现选定某条记录,将访记录行的底色转为指定的颜色
我的代码如下,但只能做到选择一条记录后变色,再选择另一记录,前一记录转换后的颜色不会复原
For Each item In AMAccountGrid.Items
Dim SelectBgColor As Color
If item.Cells(5).Text = e.Item.Cells(5).Text Then
imgBtn = item.Cells(0).FindControl("Imagebutton2")
imgBtn.ImageUrl = "images/selected.gif"
SelectBgColor = Color.AliceBlue
Else
imgBtn = item.Cells(0).FindControl("Imagebutton2")
imgBtn.ImageUrl = "images/select.gif"
SelectBgColor = Color.Pink
End If
Next
e.Item.BackColor=SelectBgColor