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:
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="1">
<ajaxToolkit:TabPanel runat="server" HeaderText="TabPanel1" ID="TabPanel1">
<HeaderTemplate>
Names
</HeaderTemplate>
<ContentTemplate>
<asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" RepeatColumns="5" ForeColor="Red"
RepeatLayout="Table" >
<ItemTemplate>
<asp:LinkButton Text = '<%#Eval("names")%>' ID="lnkpro" runat="server" ForeColor="Red" OnClick="btn_Click"></asp:LinkButton>
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
</ajaxToolkit:TabContainer>
in cs 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);
}
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.