wasteofbreath14
New Member
I am new to ASP.Net.I am working with C# enviroment and I have this code below that I tested and it works under VB\[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\]So, I try to convert it to C# language and couldn't get it to work.1) There is no "handles" option in C#2) Somehow, "e.Row.Attributes("onclick")" works in VB, but not 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\]Please help!