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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:09:56+00:00 2026-05-19T03:09:56+00:00

I have the following working so far in C# on my Gridview called GridView1.

  • 0

I have the following working so far in C# on my Gridview called GridView1. It works when I put it in the onSelectedIndexChanged.

HostTextbox.Text = GridView1.SelectedRow.Cells[0].Text;

but since this posts back to the server I want to avoid it because I will be doing it for cells[0] to cells[10]. So, I looked into Javascript. I googled around and found various solutions and this is the one I have “semi-working” so far.

My C# looks like this:

int myRowIdx = 0; // class variable 

protected void OnRowCreated(object sender, GridViewRowEventArgs e)  
    {  
        if (e.Row.RowType == DataControlRowType.DataRow)  
        {
            e.Row.Attributes.Add("ondbclick", "sample('" + myRowIdx.ToString() + "')");
        }  
        myRowIdx++;  
    }

In my Javascript I inserted alerts to tell me where the problem happpens. It looks like this:

   function sample(rowIn) {  
        alert("A");  
        var gViewID = '<%= GridView1.ClientID %>';  
        alert("B");  
        var gView = getElementById(gViewID);  
        alert("C");  
        var gViewRow = gView.rows[rowIn];  
        alert("D");  
        var gViewRowColumn = gViewRow.cells[0];  
        alert("E");  
        var displayCell = gViewRowColumn.innerText;  
        alert("F");  
        alert(displayCell);  
    }

B is the last alert I see. I can’t seem to figure this out. I looked carefully into it and still no success. Please help.

  • 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-19T03:09:56+00:00Added an answer on May 19, 2026 at 3:09 am

    I don’t understand what you mean with “I want to avoid it because I will be doing it for cells[0] to cells[10]”. You could do that for each cell in the selected row successively. So you only need one Postback.

    According to your Javascript problems, you could simply pass the tr(GridViewRow) as js-variable to your sample-function. Therefore you only have to pass this as parameter:

     e.Row.Attributes.Add("ondbclick", "sample(this)");
    

    and in your js-function:

     function sample(tr) {  
          var gViewRowColumn = tr.cells[0];  
          var displayCell = gViewRowColumn.innerText;  
          alert(displayCell);  
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far i have the following code, but it doesn't seem to be working,
I have the following UserDetailsService implementation. The authentication process is working great so far.
I have the following code that works: <script type=text/javascript> $(document).ready(function() { // Initialise the
I have the following working tar -pcvf base.tar input/myPacket/my2 --exclude-vcs input/myPacket/my3/*.bmp When i have
In YUI I have following code working for mouse wheel. How do I make
We have the following code working for a complex rails form with checkboxes. I'm
Right now I have the following code working: @UiHandler(usernameTextBox) void onUsernameTextBoxKeyPress(KeyPressEvent event) { keyPress(event);
I have following code And it is working fine in AIR device simulator on
I am working with NSCache in iOS i have following code in .h file
On a Solaris 5.8 machine, I have the following code: [non-working code] char *buf;

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.