你问如何在DataGrid控件中鼠标移动到某行使某行变颜色?
请大家帮忙..我是.net的新手!!!!!!!!
刚才有发贴问过但少打了DataGrid控件中...
问题点数:10、回复次数:5Top
1 楼artak(甜葡萄)回复于 2006-03-03 12:43:40 得分 0
private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='red'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='white'");
}
}
Top
2 楼baobei7758(陵少)回复于 2006-03-03 12:44:05 得分 10
private void dg_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
//删除确认
LinkButton delBttn = (LinkButton) e.Item.Cells[1].Controls[0];
delBttn.Attributes.Add("onclick","javascript:return confirm('确定删除" + e.Item.Cells[4].Text + "?');");
//颜色交替
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='seashell'");
if(e.Item.ItemType == ListItemType.Item)
{
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'");
}
if(e.Item.ItemType ==ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='seashell'");
}
}
}
Top
3 楼shenghuayi(oldman)回复于 2006-03-03 12:44:29 得分 0
in itemdatabound:
e.item.Attributes("onmouseover","this.style.backColor='red';")
e.item.Attributes("onmouseout","this.style.backColor='white';")
Top
4 楼jiangpan()回复于 2006-03-03 13:18:00 得分 0
我每行的颜色可能会不同..怎么变回原来的颜色?Top
5 楼jiangpan()回复于 2006-03-03 13:25:07 得分 0
对不起.2楼以讲...谢谢了Top




