在ItemDataBound事件中为控件加载属性时遇到的问题

jlqidan jlqidan 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
为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.
谁有更好的办法吗?
...全文
评论 3
收藏 已收藏
分享
返回顶部
jlqidan
.NET社区 62,274 成员 668,968 内容