I am trying to find a way of passing the number of dynamic controls I have created in the page init phase and be able to read it on post back so I can recreate the controls.
I tried session["myvariable"] = num as well but couldn't get that to work either
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (!IsPostBack)
{
int x = 1;
this.NumberOfControls = 17; ........
protected int NumberOfControls
{
get { return (int)ViewState["NumControls"]; }
set { ViewState["NumControls"] = value; }
}
after postback
I want read the variable NumberOf Controls
but error says it is a null reference
protected void Button1_Click(object sender, EventArgs e)
{
int count = this.NumberOfControls;
I tried session["myvariable"] = num as well but couldn't get that to work either
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (!IsPostBack)
{
int x = 1;
this.NumberOfControls = 17; ........
protected int NumberOfControls
{
get { return (int)ViewState["NumControls"]; }
set { ViewState["NumControls"] = value; }
}
after postback
I want read the variable NumberOf Controls
but error says it is a null reference
protected void Button1_Click(object sender, EventArgs e)
{
int count = this.NumberOfControls;