在ItemDataBound事件中为控件加载属性时遇到的问题
为DataGrid控件应用了如下属性<AlternatingItemStyle BackColor="white"></AlternatingItemStyle>
在ItemDataBound事件处理函数中有如下语句:
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='LightGrey';this.style.cursor='hand'");
现在的问题是当我鼠标移开时,DataGrid控件被选中的那行颜色不能回复,试过几种写法,均达不到目的.
本来想如此这般:(也是在ItemDataBound事件处理函数中,但在上面那条语句之前)
Color cl = new Color();
cl = e.Item.BackColor;
可是这样也取不到当前行的颜色.跟踪执行发现cl为empty.
谁有更好的办法吗?