Click here to Skip to main content
15,921,212 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to get an events of button which are dynamically generates??
Posted
Comments
Sergey Alexandrovich Kryukov 13-Mar-12 1:30am    
Not clear.
--SA
Prasad_Kulkarni 13-Mar-12 2:21am    
sir he just wants the events of button which is created dynamically. And i have given answer for same. Someone downvoted it :( i don't think its incomplete answer or not proper.
Sergey Alexandrovich Kryukov 14-Mar-12 2:48am    
I don't just know if your answer is good or not. Do you know why C# and PHP? What does it mean?! What is "wants events"? Want what? If your answer is good for Forms, WPF or something, it does not mean it helps, because the question remains mysterious. Why answering something we do not understand? Or you do? :-)
--SA
Prasad_Kulkarni 14-Mar-12 4:02am    
Hmmm C# and PHP, My apologise. I won't any more sir.
Sergey Alexandrovich Kryukov 14-Mar-12 4:38am    
No problems. The problem is the vague question, that's it...
--SA

1 solution

Check this out:
C#
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{         
    LinkButton ln = new LinkButton();
    ln.Text = ds.Tables[0].Rows[i].ItemArray[0].ToString();
    ln.ID =  ds.Tables[0].Rows[i].ItemArray[1].ToString();  
    ln.Click += new EventHandler(Clicked);
    divonlne.Controls.Add(ln);
    divonlne.Controls.Add(new LiteralControl("<br />"));
}

Have a look Dynamically created button in asp.net and c#[^]
Dynamically Created Controls in ASP.NET[^]
Custom Event Handler for a Dynamically Created Control Embedded in Another Control[^]
Flex Style Programming: Handling Dynamically Created Controls[^]
 
Share this answer
 
v2

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