You must Sign In to post a response.
  • Category: .NET

    Checkbox checkedchanged events dynamically

    Hi Friends.,
    dynamically i create 3 checkboxes in my form. i need code to checkedchange events of specific checkbox only .

    Thanks & Regards.,
  • #765412
    Add event handler when you create a checkbox programmatically. And its handler you can do your code logic.
    see below snippet
    CheckBox dynamicCheckBox = new CheckBox();
    dynamicCheckBox.CheckedChanged +=new EventHandler(dynamicCheckBox_CheckedChanged);
    private void dynamicCheckBox_CheckedChanged(object sender, EventArgs e)
    // Your code

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #765421

    If you want to perform checked changed event of your dynamic checkbox, refer below sample code for your reference.

    CheckBox chk1= new CheckBox();
    chk1.Text = "YourText";
    chk1.ID = "chk1";
    chk1.Checked = true;
    chk1.AutoPostBack = true;

    chk1.CheckedChanged += new EventHandler(chk1_CheckedChanged);

    protected void chk1_CheckedChanged(object sender, EventArgs e)
    //your code

    You can follow above code to achieve your goal...

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

Sign In to post your comments