Gridview:保持SelectedRow的风格

时间:2010-02-11 10:38:03

标签: asp.net gridview

我通过样式表更改了normal,alternate和selected行的样式。另外,我用gv_Alternativen_RowDataBound实现了onmouseover,onmouseoout和class。

但是当我在所选行中执行鼠标悬停时,会在那里放置错误的onmouseout:

    Protected Sub gv_Alternativen_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gv_Alternativen.RowDataBound
    If e.Row.RowType = DataControlRowType.DataRow Then
        Select Case e.Row.RowState
            Case Is <> DataControlRowState.Selected
                'odd even
                If e.Row.RowState = DataControlRowState.Normal And e.Row.RowState <> DataControlRowState.Selected Then
                    e.Row.Attributes.Clear()
                    e.Row.Attributes.Add("onmouseout", "this.className='PopupAngeboteRow'")
                    e.Row.Attributes.Add("onmouseover", "this.className='PopupAngeboteRowHover'")
                    e.Row.Attributes.Add("class", "PopupAngeboteRow")
                ElseIf e.Row.RowState = DataControlRowState.Alternate And e.Row.RowState <> DataControlRowState.Selected Then
                    e.Row.Attributes.Clear()
                    e.Row.Attributes.Add("onmouseout", "this.className='PopupAngeboteAlternatingRow'")
                    e.Row.Attributes.Add("onmouseover", "this.className='PopupAngeboteRowHover'")
                    e.Row.Attributes.Add("class", "PopupAngeboteAlternatingRow")
                End If
            Case Is = DataControlRowState.Selected
                e.Row.Attributes.Clear()
                e.Row.Attributes.Add("onmouseover", "this.className='PopupAngeboteRowSelected'")
                e.Row.Attributes.Add("onmouseout", "this.className='PopupAngeboteRowSelected'")
                e.Row.Attributes.Add("class", "PopupAngeboteRowSelected")
        End Select
    End If
End Sub

任何想法???

提前很多,问候......

1 个答案:

答案 0 :(得分:0)