不是有 alternativeitemstyle 和 itemstyle

解决方案 »

  1.   

    alternativeitemstyle back color
      

  2.   

    (1)
    <asp:datagrid id="datagrid1" AlternatingItemStyle-Backcolor="#000000" />
    (2)
    <asp:datagrid id="datagrid1">
    <alternatingitemstyle backcolor="#000000"/></asp:datagrid>
      

  3.   

    有问题呀,我在itemstyle中使用CSSCLASS定义一种样式
    又在alternatingitemstyle中定义了一种样式也是用CSSCLASS
    可是没有反应是为什么呢?
      

  4.   


    <asp:datagrid id="d_info"  OnItemDataBound="dg_bind".......>.cs
    --------------------------------------------------------
    public void dg_bind(object sender,DataGridItemEventArgs e)
    {
    if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='#0099FF',this.style.cursor='hand',this.style.ForeColor='white'");
    }
    }
      

  5.   

    or sorry:
    forget "onmouseout"please add:e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='white',this.style.cursor='hand'");
      

  6.   

    第1个问题用alternatingitemstyle 的backcolor和itemstyle的backcolor即可;
    第2个问题可用javascript使用,也可在datagrid的itembound事件中使用

    if((e.item.itemstyle==ListItemType.Item)||(e.item.itemstyle==ListItemType.AlternatingItem))
    {
    e.item.Attributes["onmouseover"]="this.style.backgroundcolor='red',this.cursor='default';
    e.item.Attributes["onmouseout"]="this.style.backgroundcolor='blue',this.cursor='hand';}