G
Gary Rynearson
I have an aspx form that conatains a WebControls.Table object. I also have
a class inheriting from the WebControl class. That class is instantiated
using the Table as a parameter, and adds checkboxes into rows / cells, as
shown in the code below.
The page loads fine, but after a postback, the checkboxes do not appear.
Can anyone provide assistance on getting them to persist?
Gary
public class RolesCheckBoxes : System.Web.UI.WebControls.WebControl
{
ImportContacts.BSTRoles _bstRoles = null;
Table _tbl;
string _test = string.Empty;
public RolesCheckBoxes( ImportContacts.BSTRoles bstRoles, Table tbl )
{
_bstRoles = bstRoles;
_tbl = tbl;
}
protected override void CreateChildControls()
{
Table tbl = _tbl;
TableRow row = new TableRow();
TableCell cell = new TableCell();
HyperLink a = new HyperLink ();
CheckBox ckBx = new CheckBox();
foreach (DataRow currRow in _bstRoles.Roles.Tables[0].Rows)
{
row = new TableRow();
cell = new TableCell();
ckBx = new CheckBox();
ckBx.Text = currRow["Name"].ToString ();
ckBx.ID = currRow["Code"].ToString ();
cell.Controls.Add (ckBx);
row.Cells.Add (cell);
tbl.Rows.Add (row);
}
tbl.BorderWidth = 1;
tbl.BorderStyle = BorderStyle.Ridge;
}
}
}
a class inheriting from the WebControl class. That class is instantiated
using the Table as a parameter, and adds checkboxes into rows / cells, as
shown in the code below.
The page loads fine, but after a postback, the checkboxes do not appear.
Can anyone provide assistance on getting them to persist?
Gary
public class RolesCheckBoxes : System.Web.UI.WebControls.WebControl
{
ImportContacts.BSTRoles _bstRoles = null;
Table _tbl;
string _test = string.Empty;
public RolesCheckBoxes( ImportContacts.BSTRoles bstRoles, Table tbl )
{
_bstRoles = bstRoles;
_tbl = tbl;
}
protected override void CreateChildControls()
{
Table tbl = _tbl;
TableRow row = new TableRow();
TableCell cell = new TableCell();
HyperLink a = new HyperLink ();
CheckBox ckBx = new CheckBox();
foreach (DataRow currRow in _bstRoles.Roles.Tables[0].Rows)
{
row = new TableRow();
cell = new TableCell();
ckBx = new CheckBox();
ckBx.Text = currRow["Name"].ToString ();
ckBx.ID = currRow["Code"].ToString ();
cell.Controls.Add (ckBx);
row.Cells.Add (cell);
tbl.Rows.Add (row);
}
tbl.BorderWidth = 1;
tbl.BorderStyle = BorderStyle.Ridge;
}
}
}