add/remove user (Neil Meredith control problem)
-
i used similar code by Neil Meredith. dynamically i add four user cntrls. when i delete the first i run into trouble(cant delete a second cntrl etc). however there is no problem with the rest. ]]> ]]> Untitled Page
Destination
Delete
public partial class SmplAuditInv : System.Web.UI.UserControl { public delegate void DeleteDl(object s, EventArgs e); public DeleteDl del; protected void Page_Load(object sender, EventArgs e) { } protected void CheckBox1_CheckedChanged(object sender, EventArgs e) { del(sender, e); } } public partial class SmpAudTest : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { AddAndRemoveDynamicControls(); } private void AddAndRemoveDynamicControls() { // AurecDataAccess ada = new AurecDataAccess(); // DataSet ds = ada.TestAuditInv(); ph1.Controls.Clear(); SmplAuditInv Cntrl = null; int ControlID = 0; while (InDeletedList("uc" + ControlID)) { ControlID += 1; } //foreach (DataRow dr in ds.Tables[0].Rows) for (int i = 0; i < 4;i++ ) { if (!InDeletedList("uc" + ControlID)) { Cntrl = (SmplAuditInv)LoadControl("SmplAuditInv.ascx"); Label lb1 = (Label)Cntrl.FindControl("destLabel"); lb1.Text = "Dest:"+i; Cntrl.ID = "uc" + ControlID; Cntrl.del += new SmplAuditInv.DeleteDl(HandleRemoveUserControl); ph1
-
i used similar code by Neil Meredith. dynamically i add four user cntrls. when i delete the first i run into trouble(cant delete a second cntrl etc). however there is no problem with the rest. ]]> ]]> Untitled Page
Destination
Delete
public partial class SmplAuditInv : System.Web.UI.UserControl { public delegate void DeleteDl(object s, EventArgs e); public DeleteDl del; protected void Page_Load(object sender, EventArgs e) { } protected void CheckBox1_CheckedChanged(object sender, EventArgs e) { del(sender, e); } } public partial class SmpAudTest : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { AddAndRemoveDynamicControls(); } private void AddAndRemoveDynamicControls() { // AurecDataAccess ada = new AurecDataAccess(); // DataSet ds = ada.TestAuditInv(); ph1.Controls.Clear(); SmplAuditInv Cntrl = null; int ControlID = 0; while (InDeletedList("uc" + ControlID)) { ControlID += 1; } //foreach (DataRow dr in ds.Tables[0].Rows) for (int i = 0; i < 4;i++ ) { if (!InDeletedList("uc" + ControlID)) { Cntrl = (SmplAuditInv)LoadControl("SmplAuditInv.ascx"); Label lb1 = (Label)Cntrl.FindControl("destLabel"); lb1.Text = "Dest:"+i; Cntrl.ID = "uc" + ControlID; Cntrl.del += new SmplAuditInv.DeleteDl(HandleRemoveUserControl); ph1
You might want to ask Neil.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham