Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8645617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:35:45+00:00 2026-06-12T12:35:45+00:00

I am working with C# environment and I have the below code that I

  • 0

I am working with C# environment and I have the below code that I tested and it works under Visual Basic .Net:

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 If
End Sub

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 in C#

    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);
        }
    }
    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:35:46+00:00Added an answer on June 12, 2026 at 12:35 pm

    Change it to this:

    e.Row.Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
    

    in C# arrays are called with brackets not parantheses. Also, we use plus signs instead of ampersands to concatenate strings.

    You could also do this (to match the code directly above it):

    e.Row.Attributes.add("onclick", this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET 2.0 application that is working fine in our local environment.
I have a website that per original developer was working on local environment. I
I have the following: An environment that is working like a hash for rows
I have a working WAMP environment (Apache Friends). I decided to try Subversion and
I have Developed an Stand alone application (.jar) which is working on Linux environment,
Actually I have a file . I am working in linux environment. I need
Does anybody have any advice on working in a Date Driven Development environment? Essentially,
I am working within an intranet environment. We have both a production and development
I am working in linux bash environment, and I have many files to edit,
I have a working function that prints a grid. I have many grids. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.