I added a checkbox into my datatable
Initialization
DataTable dt = new DataTable();
DataRow dr = null;
Adding the checkbox
dt.Columns.Add(new DataColumn("CheckBoxCol", typeof(CheckBox)));
Add this new row
dr = dt.NewRow();
Problem happen when I try to initialize initial state of the checkbox of the new row
((CheckBox)dr["CheckBoxCol"]).Checked = false;
There was exception thrown that says:
Unable to cast object of type 'System.DBNull' to type *'System.Web.UI.WebControls.CheckBox'.*
Is my method wrong? Can someone advice how to cast back the DataColumn back to be CheckBox?