473,468 Members | 1,354 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Self-refreshing and non-self-refreshing controls

[sorry for the multipost but I got no response in m.p.d.f.a.webcontrols]

If I have a dropdown list ddl, and the following code appears in
Page_Load, then on each postback the rows previously added persist and I
wind up with more and more copies of the same rows. To avoid this, I
have to wrap the lines in an if (!Page.IsPostBack) block.

ddl.Items.Add("One");
ddl.Items.Add("Two");
ddl.Items.Add("Three");

But if I have a table control Table1 and do the same thing, the table
starts from scratch upon postback, so only the rows currently being
added appear in the table. Therefore, this code doesn't go in an if
(!Page.IsPostBack) block.

string[] keys = Request.Headers.AllKeys;
foreach (string key in keys)
{
TableRow row = new TableRow();
TableCell cell = new TableCell();
cell.Text = key;
row.Cells.Add(cell);
cell = new TableCell();
cell.Text = Request.Headers[key];
row.Cells.Add(cell);
Table1.Rows.Add(row);
}

Both the dropdown list control and the table control have
EnableViewState=true. So why the difference in behavior? For any given
control, how do I know which behavior to expect?
Aug 4 '06 #1
1 1285
In my experience ASP table controlls are just wierd and behave eratically,
have you found this behavour for anything other than a table control

"Harlan Messinger" wrote:
[sorry for the multipost but I got no response in m.p.d.f.a.webcontrols]

If I have a dropdown list ddl, and the following code appears in
Page_Load, then on each postback the rows previously added persist and I
wind up with more and more copies of the same rows. To avoid this, I
have to wrap the lines in an if (!Page.IsPostBack) block.

ddl.Items.Add("One");
ddl.Items.Add("Two");
ddl.Items.Add("Three");

But if I have a table control Table1 and do the same thing, the table
starts from scratch upon postback, so only the rows currently being
added appear in the table. Therefore, this code doesn't go in an if
(!Page.IsPostBack) block.

string[] keys = Request.Headers.AllKeys;
foreach (string key in keys)
{
TableRow row = new TableRow();
TableCell cell = new TableCell();
cell.Text = key;
row.Cells.Add(cell);
cell = new TableCell();
cell.Text = Request.Headers[key];
row.Cells.Add(cell);
Table1.Rows.Add(row);
}

Both the dropdown list control and the table control have
EnableViewState=true. So why the difference in behavior? For any given
control, how do I know which behavior to expect?
Aug 4 '06 #2

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

Similar topics

7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
6
by: Robert | last post by:
Hello. I have been trying out the Lebans ToolTip Classes at http://www.lebans.com/tooltip.htm, to display "balloon" style help tips in a form. The classes I am using are located at...
3
by: DBQueen | last post by:
I have a form with lines of controls. On some of the lines there are 3 controls (call them A,B,C); other lines have only control A. The controls have been numbered sequentially (Q20, Q21....Q76)...
16
by: TD | last post by:
This is the code under a command button - Dim ctl As Control For Each ctl In Me.Controls If ctl.BackColor <> RGB(255, 255, 255) Then ctl.BackColor = RGB(255, 255, 255) End If Next ctl
2
by: Das | last post by:
Hi All, Where does asp.net stores the objects declared in the page. I have a method where I want to loop through all the controls(textbox, HtmlInputText) within the page. I want to in which...
0
by: Mark Johnson | last post by:
Sometimes Controls that have been added to a GroupBox do not show up. What I am doing : 1) I am not using the designer, but create all the Controls per hand: groupBoxProdukt_01 = new...
1
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new...
7
by: Mike Bulava | last post by:
I have created a base form that I plan to use throughout my application let call the form form1. I have Built the project then add another form that inherits from form1, I add a few panel controls...
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: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.