Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to get link button id which is created at run time, my code is below.

for(int i=0;i<2;i++)
{
LinkButton lnkbtn1 = new LinkButton();
lnkbtn1.ID=i.ToString();
lnkbtn1.Text="link Button "+i.ToString();
lnkbtn1.Click += new EventHandler(lnkbtn1_Click);
pnl1.Controls.Add(lnkbtn1);
}
protected void lnkbtn1_Click(object sender, EventArgs e)
{
LinkButton lnkk1 = (LinkButton)sender;
string str = lnkk1.Text;
}

but in above code,i get only text.
Please help me
Posted

1 solution

Use
C#
string str = lnkk1.ID;
instead of lnkk1.Text
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900