title: Getting gridview column value as parameter for javascript function
body: <p>I have a gridview with certain number of columns and the ID column where I want to get the value from is currently set to visible = false. The other column is a TemplateField column (LinkButton) and as the user clicks on the button it will grab the value from the ID column and pass the value to one of my javascript function.</p>
  
  <p>WebForm:</p>
  
  <pre><code>&lt;script language=javascript&gt;
      function openContent(contentID)
      {               
      window.open('myContentPage.aspx?contentID=' + contentID , 'View Content','left=300,top=300,toolbar=no,scrollbars=yes,width=1000,height=500');
      return false;
      }
  &lt;/script&gt;
  
  &lt;asp:GridView ID="gvCourse" runat="server" AutoGenerateColumns="False" OnRowCommand="gvCourse_RowCommand" 
  OnRowDataBound="gvCourse_RowDataBound" BorderStyle="None" GridLines="None"&gt;
  &lt;RowStyle BorderStyle="None" /&gt;
  &lt;Columns&gt;
      &lt;asp:TemplateField&gt;
          &lt;ItemTemplate&gt;
              &lt;asp:LinkButton ID="lnkContent" runat="server" 
               CommandName="View" CommandArgument='&lt;%#Eval("contentID") %&gt;' Text='&lt;%#Eval("contentName") %&gt;'&gt;
               &lt;/asp:LinkButton&gt;  
          &lt;/ItemTemplate&gt;
      &lt;/asp:TemplateField&gt;
      &lt;asp:BoundField DataField="contentID" HeaderText="contentID" ReadOnly="True" 
          SortExpression="contentID" Visible="False" /&gt;
      &lt;asp:BoundField DataField="ContentName" HeaderText="ContentName" 
          ReadOnly="True" SortExpression="ContentName" Visible="False" /&gt;
  &lt;/Columns&gt;
  &lt;AlternatingRowStyle BorderStyle="None" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Code behind:</p>
  
  <pre><code>protected void gvCourse_RowCommand(object sender, GridViewCommandEventArgs e)
  {   
      if (e.CommandName == "View")
      {
          intID = Convert.ToInt32(e.CommandArgument);
      }
  }
  
  protected void gvCourse_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
  {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
          ((LinkButton)e.Row.FindControl("lnkContent")).Attributes.Add("onclick", "return openContent('" + intID + "');");
      }
  }
  </code></pre>
  
  <p>right not i'm trying to get the intID based on user selected item so when the user clicks on the linkbutton it will open a popup window using javascript and the ID will be used as querystring.</p>