title: DataList ItemCommand Event changing CSS class
body: <p>I have buttons in DataList control, when I click on a button, I am changing its CSS class in itemcommand event,the class is changing as expected, but when I click on button1 it will change its CSS class and after that I click on button2 it will also change its CSS class, but button1 also have same class, I want to add this class only on the button which I have clicked.
  this is my aspx code</p>
  
  <pre><code> &lt;asp:DataList ID="lst" runat="server" OnItemCommand="lst_ItemCommand"
                          Width="187"&gt;
                          &lt;HeaderTemplate&gt;
                          &lt;/HeaderTemplate&gt;
                          &lt;ItemTemplate&gt;
                              &lt;div class="num"&gt;
                                  &lt;asp:LinkButton  style="text-decoration:none;" ID="lnk" CommandName="detail" CommandArgument='&lt;%# Eval("UserID") %&gt;'
                                      runat="server"&gt;&lt;%# Eval("Title")+" "+Eval("Firstname")%&gt;&lt;/asp:LinkButton&gt;
                              &lt;/div&gt;
                          &lt;/ItemTemplate&gt;
                          &lt;FooterTemplate&gt;
                          &lt;/FooterTemplate&gt;
                      &lt;/asp:DataList&gt;
  </code></pre>
  
  <p>and this is my .CS code</p>
  
  <pre><code>   protected void lst_ItemCommand(object source, DataListCommandEventArgs e)
          {
  
              if (e.CommandName == "detail")
              {
              LinkButton btnlnk = (LinkButton)e.Item.FindControl("lnk");
                  btnlnk.CssClass = "selectedclass";
                }
  
  
          }
  </code></pre>