Get Bound Fields value of gridview to javascript function

Posted on 2011-05-10
Last Modified: 2012-05-11
     Hello experts,
                  I am trying to pass value of gridveiw  bound field to javascript.
                  To achieve it I attempted to use HyperlinkField
                   and pass js function call to DataNavigateUrlFormatString but it does not work
                  Please advise.

            <asp:GridView ID="gvVendorDetails" runat="server" AutoGenerateColumns="false">
                                <asp:HyperLinkField DataNavigateUrlFields="SiteUtilizationID,Manager "
                                    DataNavigateUrlFormatString="javascript:test(FieldValue);" DataTextField="SiteUtilizationID"
                                    HeaderText="Site Utilization ID" />
                                <asp:HyperLinkField DataNavigateUrlFields="SiteUtilizationID,Manager "
                                    DataTextField="Manager" HeaderText="Manager" />                                
Question by:Vadim2004
    LVL 9

    Expert Comment


    LVL 13

    Expert Comment

    Something like this?!?
    function GetCellValue() {
     var gridview = document.getElementById("<%= GridView1.ClientID %>");
     var gCell;
     if (grid.rows.length > 0) {
      for (i = 1; i < grid.rows.length-1; i++) {
          gCell = grid.rows[i].cells[0].InnerHtml;
          // Do Whatever

    Open in new window


    Author Comment

    TonyReba, rick  - thank you for quick response.
    but, I was tryied -

    Result this error:

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

    Requested URL: /ETMProject/test();

    Accepted Solution

    Here is solution:
      protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
            e.Row.Attributes.Add("onclick", "test()");
    <asp:HyperLinkField DataNavigateUrlFields="SiteUtilizationID,Manager "
           DataTextField="Manager" HeaderText="Manager" />                                
    LVL 19

    Expert Comment

    by:Amandeep Singh Bhullar
    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now