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 7172205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:34:09+00:00 2026-05-28T15:34:09+00:00

I am currently working in ASP.Net / C#. I am trying to make the

  • 0

I am currently working in ASP.Net / C#. I am trying to make the server redirect to another page using via the rows in a datagrid, however, my code doesn’t seem
to work. Any help would be appreciated.

  protected void GridView1_RowCreated()
{
    foreach (GridViewRow row in GridView1.Rows)
    {
        Color color = row.BackColor;
        string color2 = System.Drawing.ColorTranslator.ToHtml(color);
        Session["" + row.Cells[0].Text + ""] = row.Cells[0].Text;
        //row.Attributes.Add("onclick", "zz(); return false;");
        /*if (row.RowState == DataControlRowState.Alternate)
        {
            row.Attributes.Add("onclick", "redirectFunction(); return false;");
            //row.Attributes.Add("onmouseover", "this.style.backgroundColor='   #FFFFFF';");
            //row.Attributes.Add("onmouseout", "this.style.backgroundColor='" + color2 + "';");
            //row.Attributes.Add("onclick", cookie.Value = row. GridView1.SelectedRow.Cells[0].Text);
            //row.Attributes.Add("onclick", "zz(); return false;");
        }
        else
        {
            //row.Attributes.Add("onmouseover", "this.style.backgroundColor='   #FFFFFF';");
            //row.Attributes.Add("onmouseout", "this.style.backgroundColor='" + color2 + "';");
            //row.Attributes.Add("onclick", "zz(); return false;");
        }*/
    }
}

        public void redirectFunction()
        {
    Response.RedirectPermanent("View.aspx");
        }

        Other page 
        if(Session["session"].ToString() != null)
        {
            // do something
        }
  • 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-05-28T15:34:10+00:00Added an answer on May 28, 2026 at 3:34 pm

    It looks like you are adding a client side on click event and then trying to call a c# method which won’t work.

    This code:

    foreach (GridViewRow row in GridView1.Rows)
    {
        row.Attributes.Add("onclick", "redirectFunction()");
        // Or if you want to pas in an id
        row.Attributes.Add("onclick", "redirectFunction(" + rowId + ")");
    }
    

    is adding a javascript click event to the row and you are telling it to call a javascript method. You then need to add the javascript method to your aspx page:

    <script type="text/javascript">
        function redirectFunction() {
           alert("do you see this??");
           window.location = "View.aspx";
        }
    </script>
    

    I have added an alert statement, you can get rid of it but do you see this popup? If not check for any javascript errors on the page.

    You could also do this with jQuery (it’s much easier):

    $('.yourrowclassname).click(function () {
        window.location = "View.aspx";
    });
    

    This means you do don’t need to add the attribute in code, just use/add a class to the row.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working on a ASP.Net 3.5 project and trying to implement session timeout
The ASP.net page I am currently working on has a drop down list that
I am currently working on my first asp.net mvc application. I am trying to
Currently I'm working on a reporting website in VS 2010 using ASP.Net 4.0 and
I'm currently working on an ASP.NET MVC project using NHibernate and I need to
Currently I'm trying to understand dependency injection better and I'm using asp.net MVC to
Here I am working with jquery data table plugin in asp.net page I'm currently
I'm currently working in asp.net mvc 4 and I'm trying to add the fullcalendar
I am currently working in ASP.NET MVC 4 while using the entity framework. I've
I am currently working on an ASP.NET MVC project. Some developers on the team

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.