Ekrem Tapan

Ekrem Tapan

  • NA
  • 967
  • 80.9k

how can i keep my user control ?

Oct 17 2016 1:48 AM
Hi everyone 
 
this is my page load code then when i wantto edit my data  
  1. protected void Page_Load(object sender, EventArgs e)  
  2.    {  
  3.        if (!this.IsPostBack)  
  4.        { DataTable dtAttach = Donate.GetMatDonationAttach(SID);  
  5.                {  
  6.                    if (dtAttach.Rows.Count > 0)  
  7.                    {  
  8.   
  9.                        for (int i = 0; i <= dtAttach.Rows.Count - 1; i++)  
  10.                        {  
  11.                            Control tempControl = this.Page.LoadControl("UC/UC.ascx");  
  12.                            ((ASP.sysadmin_credit_donationmaterial_uc_uc_ascx)tempControl).EquipmentName = dtAttach.Rows[i]["ObjName"].ToString();  
  13.                            ((ASP.sysadmin_credit_donationmaterial_uc_uc_ascx)tempControl).Quantity = dtAttach.Rows[i]["Quantity"].ToString();  
  14.                            ((ASP.sysadmin_credit_donationmaterial_uc_uc_ascx)tempControl).UnitPrice = dtAttach.Rows[i]["UnitPrice"].ToString();  
  15.                            attachSID = Convert.ToInt32(dtAttach.Rows[i]["SID1"].ToString());  
  16.                            pHolder.Controls.Add(tempControl);  
  17.                        }  
  18.                    }  
  19.                }
  20.    }
  21. }  
then add another usercontrol on my page, but loaded data automatically remove on the my page 
 
 
this is my adding user control button  
  1. protected void btnAdd_Click(object sender, EventArgs e)  
  2. {  
  3.                for (int i = count; i <= _block.Count; i++)  
  4.                 {  
  5.                     if (!this._block[i].Visible)  
  6.                     {  
  7.                         this._block[i].Visible = true;  
  8.                         break;  
  9.                     }  
  10.                 }  
  11. }  
 how can i resolve when i add new usercontrol then keep old usercontrol and data ??

Answers (1)