Assign value to hidden field from SelectedItem of Listview using JQuery
<p>I am trying to add a hidden field and assign a value to it (from list view selected item) in JQuery. Can anyone please help me on this?</p>

<pre><code>&lt;SelectedItemTemplate&gt;
          &lt;tr class='results-row selected-product' id='&lt;%# Eval("GenericProductID") %&gt;'&gt;
          &lt;td class="results-item"&gt;
                &lt;asp:Label ID="lblMatchedName" runat="server" Text='&lt;%#Eval("MatchedName") %&gt;' CssClass="matched-name" /&gt;
                &lt;input type=’hidden’ class="synonym-id" value ='&lt;%#Eval("SynonymID") %&gt;' /&gt;
                &lt;input type='hidden' class="product-index" value='&lt;%# CType(Container, ListViewDataItem).DisplayIndex %&gt;' /&gt;
          &lt;/td&gt;
          &lt;td&gt;
    &lt;asp:LinkButton ID="btnSelect" runat='server' CommandName='Select' Text='Select' CommandArgument='&lt;%# Eval("GenericProductID") %&gt;' 
          CssClass='button-select'  /&gt;&lt;/td&gt;
          &lt;/tr&gt;
    &lt;/SelectedItemTemplate&gt;
</code></pre>

<p>in the above block this is the field I am trying to add, and read it in the jquery.</p>

<pre><code>&lt;input type=’hidden’ class="synonym-id" value ='&lt;%#Eval("SynonymID") %&gt;' /&gt;
</code></pre>

<p>JQuery –</p>

<pre><code>$(document).ready(function() {
                debugger;
                $('#&lt;%= loader.ClientID %&gt;').hide();
                $('#left-search-content').hide();
                $('#right-search-content').hide();
                $('.header-bottom').hide();

                $('.results-row').live('mouseover', function() { $(this).addClass('highlighted'); });
                $('.results-row').live('mouseout', function() { $(this).removeClass('highlighted'); });
                $('.search-cancel').live('click', function() {
                    $('#dialog-form').dialog('close');
                });
                $('#&lt;%= lbSearch.ClientID %&gt;').live('click', function() {
                    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndSearchHandler);
                });
                $('.results-item').live('click', function() {
                    $('.selected-product').removeClass('selected-product');
                    $(this).addClass('selected-product');
                    //$(this).parent().addClass('selected-product');

                    //var btnId = $(this).parent().find('.button-select').attr('id').replace(/_/gi, '$');
                    //__doPostBack(btnId, "");
                    $selectedProductRow = $(this).parent();
                    var productId = $(this).parent().attr('id');
                    debugger;
                    var matchedName = $selectedProductRow.find('.matched-name').html();
                    var selectedSynonymID = $selectedProductRow.find('.synonym-id').html();

                    var $hiddenField = $('#&lt;%= hdnSelectedProductID.ClientID %&gt;');
                    $('#&lt;%= hdnSelectedProductName.ClientID %&gt;').val(matchedName);
                    $('#&lt;%= hdnSelectedSynonymID.ClientID %&gt;').val(selectedSynonymID);
                    if ($hiddenField) {
                        $hiddenField.val(productId);
                        __doPostBack($hiddenField.attr('id'), '');
                    }
                    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndDetailsHandler);
                    return false;
                });

                //                  $('.search-box').live('keypress', function(e) { 
                //                        if(e.keyCode == 13) {
                //                              var btnId = $(this).parent().find('.search-button').attr('id').replace(/_/gi, '$');
                //                              __doPostBack(btnId, "");
                //                        }
                //                  });

                function OnFailed(error) {
                    alert(error.get_message());
                }

            });
</code></pre>

<p>hdnSelectedSynonymID is the hidden variable I wanted to have the selected listview item's synonymid data field.</p>
