I want to add the checkbox in DataTable and the bind ti grid view.
So I try like this.
DataTable dt = new DataTable("UserAcess");
DataColumn dc1 = new DataColumn("PageName");
dt.Columns.Add(dc1);
foreach (var item in RoleName)
{
DataColumn dc = new DataColumn(item.RoleName);
dt.Columns.Add(dc);
}
int i=0, j = 0;
foreach (var page in pageName)
{
i +=1;
DataRow dr = dt.NewRow();
dr["PageName"] = page.PAGE_NAME;
j = 0;
foreach (var role in RoleName)
{
dt.Columns.Add(new DataColumn("che" + i.ToString() + j.ToString(), typeof(System.Web.UI.WebControls.CheckBox)));
j += 1;
CheckBox ck = new CheckBox();
ck.Checked = true;
dr[role.RoleName] = ck;
}
dt.Rows.Add(dr);
}
NewDataGrid.DataSource = dt;
NewDataGrid.DataBind();
But but out put like this
I want to add the check boxes. How can I do it?