ASP.Net C# - Alternate Rows Color in Gridview
<p>I am new to ASP.Net.</p>

<p>I am working with C# enviroment and I have this code below that I tested and it works under VB</p>

<pre><code>Private Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound  
        if e.Row.RowType = DataControlRowType.DataRow then

                Dim RowNum as Integer
                RowNum = e.Row.RowIndex

                if RowNum mod 2 = 1 then

                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#DDDDDD'")

                else

                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'")

                end if

            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='DeepSkyBlue'")
            e.Row.Attributes("onclick") = Me.Page.ClientScript.GetPostBackClientHyperlink(Me.GridView1, "Select$" &amp; e.Row.RowIndex) 

        End If
End Sub
</code></pre>

<p>So, I try to convert it to C# language and couldn't get it to work.</p>

<p>1) There is no "handles" option in C#</p>

<p>2) Somehow, "e.Row.Attributes("onclick")" works in VB, but not C#</p>

<pre><code>private void GridView1_RowCreated(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        int RowNum = e.Row.RowIndex;
        if (RowNum % 2 == 1)
        {
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#DDDDDD'");
        }
        else
        {
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
        }

        e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='DeepSkyBlue'");
        e.Row.Attributes("onclick") = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" &amp; e.Row.RowIndex);
    }
}
</code></pre>

<p>Please help!  </p>
