protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { TableRow tr = new TableRow(); } else { if (Session["tblSystem"] != null) { Table tb = (Table)Session["tblSystem"]; int count = tb.Rows.Count; foreach (TableRow tr in tb.Rows) { tblSystem.Rows.Add(tr); } } } } protected void CreateTextBox(object sender, ImageClickEventArgs e) { TextBox MyTextBox = new TextBox(); //Assigning the textbox ID name ImageButton img = sender as ImageButton; TableRow row = new TableRow(); string button = img.AlternateText; switch (button) { case "System": TableCell cell = new TableCell(); TableCell cell1 = new TableCell(); ImageButton minus = new ImageButton(); cell.ID = "tblCell" + ++system; cell1.ID = "tblCell1" + system; row.ID = "tblRow" + system; minus.ID = "imgSystem" + system; minus.ImageUrl = "~/Images/minus.png"; MyTextBox.ID = "txtSystem" + system; MyTextBox.Width = 145; MyTextBox.Height = 17; MyTextBox.TextMode = TextBoxMode.SingleLine; cell.Controls.Add(MyTextBox); cell1.Controls.Add(minus); //cell.Text = "Iteration : " + system.ToString(); //cell1.Text = "Iteration : " + system.ToString(); row.Cells.Add(cell); row.Cells.Add(cell1); tblSystem.Rows.Add(row); Session["tblSystem"] = tblSystem; minus.Click += new System.Web.UI.ImageClickEventHandler(deleteRow); //pnlSystem.Controls.Add(MyTextBox); break; } } protected void deleteRow(object sender, System.Web.UI.ImageClickEventArgs e) { TableRow row = new TableRow(); ImageButton img = sender as ImageButton; string val = img.ID; string id = val.Substring(val.Length - 1, 1); if (val.Contains("System")) { TableRow rw = (TableRow)row.FindControl("tblRow" + id); rw.Visible = false; } Session["tblSystem"] = tblSystem; }
I am getting error in foreach in load event. Please help. Thanks in advance
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)