473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Deleting controls & their data from ViewState

With ASP.NET 2.0:

I have managed to create controls dynamically in an asp:table, populating
them with database info, and even adding empty rows of controls for adding
new data to the database. For all this to work I add a ViewState counter, so
far so well.

But I also want to clear the form, remove the controls and remove all
ViewState data. This is done with some code behind a button. I have tried
various kind of commands, and they all work - but I have to hit the
clear-button twice.

My guess goes for timing in the page events. The controls are loaded
dynamically in the page-load event, and I guess the clear-viewstate call
behind my clear-button is executed after this event. This is why I have to
hit the clear-button twice. But how can I make this happen in one single
postback? Any ideas?

Bjorn
Mar 28 '07 #1
1 1582
"Bjorn Sagbakken" <bj*****@online.nowrote in message
news:fM********************@telenor.com...
With ASP.NET 2.0:

I have managed to create controls dynamically in an asp:table, populating
them with database info, and even adding empty rows of controls for adding
new data to the database. For all this to work I add a ViewState counter,
so far so well.

But I also want to clear the form, remove the controls and remove all
ViewState data. This is done with some code behind a button. I have tried
various kind of commands, and they all work - but I have to hit the
clear-button twice.

My guess goes for timing in the page events. The controls are loaded
dynamically in the page-load event, and I guess the clear-viewstate call
behind my clear-button is executed after this event. This is why I have to
hit the clear-button twice. But how can I make this happen in one single
postback? Any ideas?
I guess not...ideas I mean.
So is my state of mind to, except I start to believe I need to perform a
double roundtrip to achieve this.
But how do I force a postback from server-code? (...yes I know bad
programming here will start an endless loop...)

Bjorn
Mar 31 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
8
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue...
1
by: Scott Schluer | last post by:
Hello, I've got myself a small problem and I'm hoping someone can help. I have a DataList called dlProducts (displays products from a database). Within the <ItemTemplate> container of the...
4
by: Chuck Ritzke | last post by:
Hi, I've searched the newsgroup and other sources to understand how to handle runtime controls and see I'm not the only one who's confused, but I'm still not quite sure of the best way to handle...
0
by: Don | last post by:
I need some suggests on how to manage the viewState on my page. I have multiple checkBoxLists that are dynamically created and need then synced up with the viewstate. My problem is that on each...
15
by: Arpan | last post by:
Consider the following code which retrieves data from a SQL Server 2005 DB table & displays it in a DataGrid: <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)...
8
by: mark.norgate | last post by:
I've asked this question before, but still haven't solved it, so am asking again. I am programmatically adding a user control to the page in response to a button click. The user control consists...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.