title: How to get link button text and value in datalist?
body: <p>I have an ajaxtabcontainer control in my project which contains a datalist and in datalist, I have set the names as a link button. The datalist that I am binding to a source is containing Names and age. Now I want to use the age as a selected value as we use in dropdownlist selected value? what I want is on clicking the name link button I get its value inside a label? how to do it? what I have done is as follows:
  in Default aspx:</p>
  
  <pre><code>&lt;ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"&gt;
      &lt;/ajaxToolkit:ToolkitScriptManager&gt;
      &lt;ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="1"&gt;
          &lt;ajaxToolkit:TabPanel runat="server" HeaderText="TabPanel1" ID="TabPanel1"&gt;
              &lt;HeaderTemplate&gt;
                 Names
              &lt;/HeaderTemplate&gt;
           &lt;ContentTemplate&gt;
          &lt;asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" RepeatColumns="5" ForeColor="Red"  
              RepeatLayout="Table" &gt;
  
                &lt;ItemTemplate&gt;
                &lt;asp:LinkButton Text = '&lt;%#Eval("names")%&gt;' ID="lnkpro" runat="server" ForeColor="Red" OnClick="btn_Click"&gt;&lt;/asp:LinkButton&gt;
                &lt;/ItemTemplate&gt;
              &lt;/asp:DataList&gt;
  
          &lt;/ContentTemplate&gt;
  
      &lt;/ajaxToolkit:TabContainer&gt;
  </code></pre>
  
  <p>in cs code:</p>
  
  <pre><code> protected void btn_Click(object sender, EventArgs e)
      {
  
          LinkButton myButton = sender as LinkButton;
          if (myButton != null)
          {
              Label1.Text = myButton.Text;
          }
  
      }
      protected void datalist1_ItemCommand(object source, DataListCommandEventArgs e)
      {
          int i;
          int index = Convert.ToInt32(e.Item.ItemIndex);
          LinkButton lnkid = (LinkButton)e.Item.FindControl("lnkpro");
          Label1.Text = lnkid.Text;
          i = Convert.ToInt32(lnkid.Text);
      }
  </code></pre>
  
  <p>but they are not working. the btn_click is working but giving the only name not its id. the second datalist_itemcommand is not working? Thank you.</p>