public CheckBox[] cb = null; int z=0; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { cb = new CheckBox[count - k]; //Database code......... while (dr.Read())//read data from access database { cb[z] = new CheckBox(); cb[z].Text = dr["Member_Name"].ToString(); Panel2.Controls.Add(cb[z]); Panel2.Controls.Add(new LiteralControl("</br>")); z = z + 1; } } } protected void Button6_Click(object sender, EventArgs e) { for (int x = 0; x < cb.Length; x++)//ERROR IS HERE:Object reference not set to an instance of an object. { if (cb[x].Checked == true)//EVERY TIME I GOT FALSE VALUE RATHER I CHECKED BOXES { //processing check boxes } } }
C#
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)