Hi, I've been struggling with this for the whole day... I need to create a list of buttons in a table, all buttons have the same OnClick event. I use code-behind to make the table, it's something like this: for (int i = 0; i < end; i++) { response += @"<tr><td>Data</td><td>Data2</td><td>Data3</td><td><asp:Button runat='server' /></tr>" } Of course, this doesn't work. I don't have asp:Buttons to work with. I tried to do Ajax buttons, but they also need to run on server side... Can anyone help me with that? Thanks a lot
for (int i = 0; i < end; i++) { Button btn = new Button(); btn.Text="Button "+i; btn.Click +=new EventHandler(btn_Click); Page.Controls.Add(btn); } this code adds buttons on your page, and all buttons have same click event. maybe it'll be helpfully.
Sosyopat, you're right. But this will add buttons directly to the page. I needed it to be in a table in the last column. That's why I built the table dynamically first. And then used Controls.Add()
Haiii... Thanks for you're information about that .. mybe you must used Table class..for creating dynamic server controls ... I have information about Windows Hosting provided by ASP.NET with Microsoft License ..Visit webhostforasp.net for more their windows hosting services...