ASP.NET C# - equivalent “Handles” as VB

WiseViz

New Member
I have this code in VB and it works when I test it. All the rows have alternate colors.\[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$" & e.Row.RowIndex) End IfEnd Sub\[/code\]Since I am working under C# enviroment, I converted it to C#:\[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$" + e.Row.RowIndex); }}\[/code\]Is that a way I can do same as "Handles" option in VB? Please provide me the code if possible.Thanks,
 
Back
Top