How to get nid by row click in GridView only through javascript
<p>I have a situation where i have a GridView haveing mutiple rows and columns whicha re binded well and display data in them. The code is like this:</p>

<pre><code>&lt;asp:GridView ID="dgnews" runat="server" AllowPaging="true" AutoGenerateColumns="False"
    OnRowCommand="dgnews_RowCommand"  OnPageIndexChanging="dgnews_PageIndexChanging"
    OnRowDataBound="dgnews_RowDataBound"&gt;
    &lt;Columns&gt;
        &lt;asp:TemplateField HeaderText="S.No."  ItemStyle-Width="15px"&gt;
            &lt;ItemTemplate&gt;
                &lt;%# Container.DataItemIndex + 1 %&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
        &lt;asp:TemplateField HeaderText="Transfer Date" SortExpression="assetcode" ItemStyle-Width="15%"&gt;
            &lt;ItemTemplate&gt;
                &lt;%# DataBinder.Eval(Container.DataItem, "transferdate")%&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;                                      

        &lt;asp:TemplateField HeaderText="Department" ItemStyle-Width="18%"&gt;
            &lt;ItemTemplate&gt;
                &lt;%# DataBinder.Eval(Container.DataItem, "departmentname")%&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;

        &lt;asp:TemplateField ItemStyle-Width="5px"&gt;
            &lt;ItemTemplate&gt;
                &lt;asp:LinkButton ID="lbtnedit" Visible="false" CommandName="edititem" CommandArgument='&lt;%# Eval("nid")%&gt;'
                    ToolTip="Edit" runat="server"&gt;&lt;i class="fa fa-fw" &gt;&lt;img src="images/edit.png" alt="" /&gt;&lt;/i&gt;&lt;/asp:LinkButton&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;   
    &lt;/Columns&gt;                                                    
&lt;/asp:GridView&gt;
</code></pre>

<p>And i have handled dgnews_RowCommand in my c# code by doing soemthing liek this:</p>

<pre><code>protected void dgnews_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "edititem")
    {
        Value = e.CommandArgument.ToString();// And i get the value of id of clicked row link button like this
    }
}
</code></pre>

<p>And i get the value of nid of link button clicked like this <code>"Value = e.CommandArgument.ToString();"</code> . It works fine.</p>

<p>Now what i want is to get this nid on a row click in this grid view just by javascript onclick function call. I mean, when i click a row it must call a function <code>onclick="displayHistoryThroughImages(#DataBinder.Eval(Container.DataItem,'nid'));"</code>  at  this line:</p>

<pre><code> &lt;asp:GridView ID="dgnews" runat="server" OnRowCommand="dgnews_RowCommand" OnRowDataBound="dgnews_RowDataBound"onclick="displayHistoryThroughImages(#DataBinder.Eval(Container.DataItem,'nid'));"&gt;
</code></pre>

<p>and in javascript i must get it's nid liek this:</p>

<pre><code>&lt;script&gt;
function displayHistoryThroughImages(nid)
{
    alert("row pressed with nid : "+nid );
}
&lt;/script&gt;
</code></pre>

<p>But it do not work. How to make it work ? I mean i click a row and it must call the function displayHistoryThroughImages() with the nid of that row and only in javascript.</p>