Get Bound Fields value of gridview to javascript function

     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.
                  Thanks


            <asp:GridView ID="gvVendorDetails" runat="server" AutoGenerateColumns="false">
                            <Columns>
                                <asp:HyperLinkField DataNavigateUrlFields="SiteUtilizationID,Manager "
                                    DataNavigateUrlFormatString="javascript:test(FieldValue);" DataTextField="SiteUtilizationID"
                                    HeaderText="Site Utilization ID" />
                               
                                <asp:HyperLinkField DataNavigateUrlFields="SiteUtilizationID,Manager " 
                                    DataNavigateUrlFormatString"javascript:test(FieldValue);"
                                    DataTextField="Manager" HeaderText="Manager" />                                
                        </asp:GridView>
Vadim2004Asked:
Who is Participating?
 
Vadim2004Author Commented:
Here is solution:
C#:
  protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        e.Row.Attributes.Add("onclick", "test()");
    }
HTML:
<asp:HyperLinkField DataNavigateUrlFields="SiteUtilizationID,Manager "
       DataNavigateUrlFormatString"#"
       DataTextField="Manager" HeaderText="Manager" />                                
</asp:GridView>
0
 
TonyRebaCommented:
Try

DataNavigateUrlFormatString="test(FieldValue)"
0
 
RickCommented:
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

0
 
Vadim2004Author Commented:
TonyReba, rick  - thank you for quick response.
but, I was tryied -
DataNavigateUrlFormatString="test(FieldValue)"

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();
0
 
Amandeep Singh BhullarCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.