ASP.NET - ASp.net with c# checkbox - Asked By hiren dhameliya on 07-Apr-10 05:28 AM

i want dymanicilly checkbox in my application Ex. x=20
Web Star replied to hiren dhameliya on 07-Apr-10 06:07 AM
Please describe your query in more details than u will be get proper answer.
As i understand your query u want to add dynamic checkbox on page
so u can put these line of code where u wnat to add checkbox at runtime means put it on page load or button click

CheckBox _checkbox = new CheckBox();
  _checkbox.ID = "chkDynamicCheckBox";
  _checkbox.Text = "This is a dynamically generated checkbox";
       
  Panel1.Controls.Add (_checkbox);

Rahul Kumar replied to hiren dhameliya on 07-Apr-10 06:38 AM

Here is the code to add checkbox dynamically

CheckBox cb1 = new CheckBox();
cb.Text = "Option1";

CheckBox cb2 = new CheckBox();
cb.Text = "Option2";

this.Page.Controls.Add(cb1);
this.Page.Controls.Add(cb2);

Asked By hiren dhameliya on 08-Apr-10 01:35 AM
 my application is online bus booking system .
 in  page_load event suppose Seat=50 
i want in asp x page 50 check-box create Dynamically 50 check-box 
 
hiren dhameliya replied to Web Star on 08-Apr-10 01:38 AM
my application is online bus booking system .
 in  page_load event suppose Seat=50 
i want in asp x page 50 check-box create Dynamically 50 check-box 
 suppose Seat= 20 i want them 20 check-box create Dynamically 20 check-box