title: Need to change the background color of datalist cell
body: <p>I have a datalist with itemtemplate which contains: an anchor and an href  tag . Everytime a user clicks the link I want to change the background color to green of the  so that the whole cell looks selected. If another cell is selected then the previous background should clear up and the new cell should get the green color. Right now all the td's change to green for a second and then it cjanges to the original colors. The issue is that I cannot get unique id because of the DataList control. There is a unique table name and but all the td are identical. So there are 2 issues.</p>
  
  <ul>
  <li>To have the background color remain
  until the user clicks another cell</li>
  <li>Have a unique id to recognize which
  cell was selected by the click event.</li>
  </ul>
  
  <p>How can I do that? Please help.</p>
  
  <pre><code>&lt;asp:DataList ID="DL1" ItemStyle-Width="50%"  runat="server" DataSourceID="ds1" 
          RepeatColumns="2" RepeatDirection="Vertical" RepeatLayout="Table"&gt;  
       &lt;ItemTemplate&gt;
            &lt;a onclick="testl('&lt;%= DL1.ClientID %&gt;')" 
                 href='&lt;%# "Color.aspx?id=" + Eval("id") %&gt;'&gt; 
                         Click to change background
            &lt;/a&gt; 
        &lt;/ItemTemplate&gt;
   &lt;/datalist&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>    function test(id) {
          $("#" + id + " td").css({ 'background-color': 'green' });
      }
  </code></pre>