// binding datatable Dynamically.. protected void ddlRole_SelectedIndexChanged(object sender, EventArgs e) { for (int i = 0; i < DtOperation.Rows.Count; i++) { Dt.Columns.Add(DtOperation.Rows[i][0].ToString()); } dgrDynamic.DataSource = Dt; dgrDynamic.DataBind(); . . //addind check boxes dynamically. tcCheckCell = new TableCell(); var checkBox = new CheckBox(); // ActivityID|OperationID is stored to work it at the time of Save in CheckedChanged. checkBox.ID = DtOperation.Rows[i][0] + "|" + DtOperation.Rows[i][2]; checkBox.AutoPostBack = true; checkBox.Checked = true; checkBox.CheckedChanged +=new EventHandler(checkBox_CheckedChanged); tcCheckCell.Controls.Add(checkBox); dgrDynamic.Rows[j].Cells.RemoveAt(GetColumnIndexByName((int)DtOperation.Rows[i][2])); dgrDynamic.Rows[j].Cells.AddAt(GetColumnIndexByName((int)DtOperation.Rows[i][2]), tcCheckCell); //(int)DtOperation.Rows[i][2]+2 } void checkBox_CheckedChanged(object sender, EventArgs e) { ...Code; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)