jQuery Val() Function Cannot Change Dropdownlist Selected Value

jQuery Val() Function Cannot Change Dropdownlist Selected Value

I have a VB.net web form that consists of a dropdownlist called ddlAuthor, a textbox called txtYear, a search button, and an asp.net gridview. After user selects the author's name in the ddlAuthor dropdownlist box, type in the year in the txtYear textbox, and click  the search button, a gridview called AuthorGridView will show up. 

The gridview consists of  Author , Book Title, Year of Publication, and Coauthors columns. The left most column in each row of the gridview contains the Edit link followed by other columns. The Edit link is just a regular HTML anchor element and when it's clicked I would like to set the selected value of ddlAuthor to the Author name in the same row as the clicked Edit link.  

I did some research on setting the value of a dropdown using jQuery and found many posts suggesting people to use jQuery val() function. I tried it but it didn't work.

Because I'm using asp.net controls their IDs will be altered when the page is rendered in the browser and I have to use a special code to grab the ID of each control to be used by jQuery.

When I click the Edit link in the gridview, I was able to grab the Author name in the column next to it using the jQuery script below.

  1.  $("Table#ctl00_Content_AuthorGridView > tbody tr").click(function () {

  2. //The prefix Table#ctl00_Content_ is added to the real ID
  3. // of the gridview when the page is rendered  

  4.      author = $(':nth-child(2)', this).text();
  5.      alert("Author Name : " + author ); // The alert actually shows the Author name 
  6.       $('#<%=ddlAuthor.ClientID%>').val(author); 

  7. // I had to surround the ID of the ddlAuthor dropdown in order
  8. // to let jQuery know that the real ID of the dropdown is ddlAuthor

  9.  });

The alert shows the name of the Author which is in the column next to the clicked Edit link but I was not able to set the selected value of ddlAuthor dropdown using the line below. 

  1. $('#<%=ddlAuthor.ClientID%>').val(author);