aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

How to Create Controls Dynamically in code behind files using

Sep 26, 2010

Here I will explain how to generate the controls dynamically in code behind using


Hi here I will explain how to generate the controls dynamically in code behind
First design the your aspx page with one panel like this 

<html xmlns="">
<head id="Head1" runat="server">
<form id="form2" runat="server">
<asp:Panel ID="Panel1" runat="server">

After that write the following code in page load method like this 

protected void Page_Load(object sender, EventArgs e)
Table tbldynamic = new Table();
for (int i = 0; i < 5; i++)
TableCell tc = new TableCell();
TableRow tr = new TableRow();
CheckBox _checkbox = new CheckBox();
_checkbox.ID = "chkDynamicCheckBox" + i;
_checkbox.Text = "Checkbox" + i;

Now run application you will see dynamically generated checkboxes like that we can generate controls dynamically.

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


harikishore said...

nice and excellent articles

Anonymous said...


How to write "CheckedChanged" Event for each CheckBox.

Anonymous said...

can u explain how to work with events of dynamically created controls like managing ControlId,events of dynamic control

Anonymous said...

Suresh Please reply to the above comments 2 and 3.

Anonymous said...

Hope this works!!!!! :)

Button btnDyn = new Button();
btnDyn.ID = "btnDyn";
btnDyn.Style["Position"] = "Absolute";
btnDyn.Style["Top"] = "100px"; btnDyn.Style["Left"] = "10px";
btnDyn.Click += new EventHandler(Button_Click);

Anonymous said...

nice site and excellent tutorials...

shawn said...

But How to find that checkbox ////
when we going to click a button to get value of selected check boxes

gaurav mamidwar said...

Thanx for good guidence.....

mohit srivastava said...

hi suresh you are rock man.
can you help me to make a project like book a seat
where i create dynamic seats(img btn)
and make event on all of it

Anonymous said...

I am not able to Print the dynamic table ....
plz help me


Anonymous said...

dynamic table with label and textboxs
plz help me

sarita khaire said...

I have created one dynamic table .and this table contains Button in each row.I want to access value from each cell on button click event ..How can i do plz give me explain..

Anonymous said...

what about radiobuttons list

mohammad noorani said...

hi thank you for your helpful Article
i have a problem with this
when i want to add text and control in one tablecell just return me one of them
what should i do?

yogesh niranjan said...

Hi Suresh, you are rock, your code will help us in many critical situation.

Thanks a lot.

Anonymous said...

Superb and Simple implementation........

Anonymous said...

its good article...but how to retrieve the same dunamically created html controls values in a button click.

bhavesh thumar said...

Hello dear

i have to create drag and dropable control in like visual studio online i can drag my panel please tell me some idea about them..

Give your Valuable Comments

Other Related Posts

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.