Click here to Skip to main content
15,926,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
am creating dynamic controls and removing controls on remove button click event. If i have 5 controls and if want to remove the first control it will remove the first control and rebind the create the control again.. now as the id matches it is loading from view state.. How to avoid it..?
Posted

I tried

ViewState.Clear(); and

this.ViewState.Remove("TextBoxSessionID" + i.ToString());


tblSessions.Rows[i - 1].Cells[0].Controls[0].ID = "TextBoxSessionID" + i.ToString();

but still its not clearing the view state value
 
Share this answer
 
Hi,
when u click to remove the control from the page write the following code before your code.

this.viewstate.remove("id");

this code remove the id of ur control from viewstate then delete your control.then create same control with the same and and then rebind it. I hope this will work for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900