mardi 29 août 2017

Error in adding Checked Changed Event to a checkbox- which is added dynamically to a gridview in asp.net application using c#

This is my code

    foreach (GridViewRow row in GridView1.Rows)
        {
            dataReader.Read();
            if (row.RowType == DataControlRowType.DataRow)
            {
                CheckBox cb = new CheckBox();
                cb.ID = "chkbox";
                if (int.Parse(dataReader[0].ToString()) == 0)
                    cb.Checked = false;
                else
                    cb.Checked = true;
                cb.CheckedChanged += new EventHandler(chkBoxChange);
                row.Cells[4].Controls.Add(cb);

            }
        }

But even though I had wriiten

       cb.CheckedChanged += new EventHandler(chkBoxChange);

the function

    public void chkBoxChange(object sender, EventArgs e){                   
    }

is not invoking when i checked the checkbox.

Please help me...




Aucun commentaire:

Enregistrer un commentaire