开发者

Gridview: Keep style of SelectedRow

I change the styles of the rows normal, alternate and selected via stylesheets. Additionally I implemented onmouseover, onmouseoout and class with gv_Alternativen_RowDataBound.

But when I do a mouseover in the selected row, the wrong onmouseout is placed there:

    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

Any ideas???

thx a lot in advance, greetings...


protected void gvHolds_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if ((e.Row.RowIndex % 2) == 0)
            {
                if (e.Row.RowIndex == gvHolds.SelectedIndex) 
                {
                    e.Row.Attributes["onmouseout"] = "this.className = 'SelectedRow';";
                    e.Row.Attributes["onmouseover"] = "this.className = 'MouseOverRow';";
                }
                else
                {
                    e.Row.Attributes["onmouseout"] = "this.className = 'oddRow';";
                    e.Row.Attributes["onmouseover"] = "this.className = 'MouseOverRow';";
                }
            }
            else
            {
                if (e.Row.RowIndex == gvHolds.SelectedIndex) 
                {
                    e.Row.Attributes["onmouseout"] = "this.className = 'SelectedRow';";
                    e.Row.Attributes["onmouseover"] = "this.className = 'MouseOverRow';";
                }
                else
                {
                    e.Row.Attributes["onmouseout"] = "this.className = 'evenRow';";
                    e.Row.Attributes["onmouseover"] = "this.className = 'MouseOverRow';";
                }
            }

            e.Row.Attributes["onclick"] = ClientScript.GetPostBackEventReference(this.gvHolds, "Select$" + e.Row.RowIndex);
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜