Setting HiddenField value in a GridView by javascript
<p>I have following code:</p>

<pre><code>&lt;asp:GridView ID="grid" runat="server" GridLines="Horizontal" Width="100%"
                AutoGenerateColumns="False" OnRowDataBound="grid_RowDataBound"&gt;
    &lt;RowStyle CssClass="gridview" /&gt;
    &lt;AlternatingRowStyle CssClass="gridviewalt"/&gt;
    &lt;Columns&gt;
        &lt;asp:BoundField ReadOnly="True" HeaderText="" DataField="fld1"&gt;
            &lt;ItemStyle HorizontalAlign="Left" Width="20%"&gt;&lt;/ItemStyle&gt;
        &lt;/asp:BoundField&gt;

        &lt;asp:BoundField ReadOnly="True" HeaderText="" DataField="fld2"&gt;
            &lt;ItemStyle HorizontalAlign="Left" &gt;&lt;/ItemStyle&gt;
        &lt;/asp:BoundField&gt;

        &lt;ItemTemplate&gt;
            &lt;asp:Label ID="lblData"  runat="server" Width="250px" Font-Bold="false" Text='&lt;%# Eval("val1") %&gt;'&gt;&lt;/asp:Label&gt;
        &lt;/ItemTemplate&gt;

        &lt;HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
        &lt;ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" Width="35%" /&gt;

        &lt;/asp:TemplateField&gt;

        &lt;asp:TemplateField HeaderStyle-VerticalAlign="Middle" HeaderStyle-HorizontalAlign="Right" Visible="false"&gt;
           &lt;ItemTemplate&gt;
                &lt;asp:HiddenField runat="server" ID="lblHdnData" /&gt;
            &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
    &lt;/Columns&gt;
&lt;/asp:GridView&gt;
</code></pre>

<p>Now in javascript, I want to set data in hidden field named <strong>lblHdnData</strong> for a perticular row.</p>

<p>I know <code>document.getElementById</code>, and setting the value, but it would be only when HiddenField will not be in GridView. As every row will have different hidden fields and different corresponding data.</p>

<p>How can I do this???</p>
