473,385 Members | 1,772 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,385 software developers and data experts.

C# - Dynamically Creating Table - Losing ViewState

Hello,

I have an asp:table on my page. I am, after a button gets clicked,
programmatically adding rows and their cells. Using the Cell.Text = to put
the value in the cell. I then have another button (which will eventually
print form the server) that refreshes the page of course. When the page gets
refreshed, none of my rows of the table (except the static header area)
remain.

I figured it was an .EnableViewState issue so I do a foreach on the
Page.Controls and set it to true. This changes nothing.

How can I dynamically create a table and have it remember upon refresh?

TIA,
Grigs
Nov 18 '05 #1
4 12392
U need to reload the whole process (programmatically adding rows and their
cells) on postback.

Vinay

"Grigs" wrote:
Hello,

I have an asp:table on my page. I am, after a button gets clicked,
programmatically adding rows and their cells. Using the Cell.Text = to put
the value in the cell. I then have another button (which will eventually
print form the server) that refreshes the page of course. When the page gets
refreshed, none of my rows of the table (except the static header area)
remain.

I figured it was an .EnableViewState issue so I do a foreach on the
Page.Controls and set it to true. This changes nothing.

How can I dynamically create a table and have it remember upon refresh?

TIA,
Grigs

Nov 18 '05 #2
Most likely, you are refreshing the data after you are adding the rows. For
example, adding rows in Page_Load, but getting the data in a button click
event. Step through in the debugger and you will likely see where you are
refreshing.

NOTE that some items are not automagically stored in ViewState, as you would
expect. If the ASP:Table is created by binding to data, you are best to cache
the DataSet (ViewState is fine) and update rows before binding. you can keep
the updated result set in ViewState if you do not want to update the data
source with each row.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Grigs" wrote:
Hello,

I have an asp:table on my page. I am, after a button gets clicked,
programmatically adding rows and their cells. Using the Cell.Text = to put
the value in the cell. I then have another button (which will eventually
print form the server) that refreshes the page of course. When the page gets
refreshed, none of my rows of the table (except the static header area)
remain.

I figured it was an .EnableViewState issue so I do a foreach on the
Page.Controls and set it to true. This changes nothing.

How can I dynamically create a table and have it remember upon refresh?

TIA,
Grigs

Nov 18 '05 #3
Uh, isn't that the point of EnableViewState? Or am I missing something?

Not to mention, I am putting a check box in one of the columns and depending
on if it is checked or not, I want to be able to extract that data out. If I
have to rebuild this table each time, how would I remember the check box?

Kevin

"vinay" wrote:
U need to reload the whole process (programmatically adding rows and their
cells) on postback.

Vinay

"Grigs" wrote:
Hello,

I have an asp:table on my page. I am, after a button gets clicked,
programmatically adding rows and their cells. Using the Cell.Text = to put
the value in the cell. I then have another button (which will eventually
print form the server) that refreshes the page of course. When the page gets
refreshed, none of my rows of the table (except the static header area)
remain.

I figured it was an .EnableViewState issue so I do a foreach on the
Page.Controls and set it to true. This changes nothing.

How can I dynamically create a table and have it remember upon refresh?

TIA,
Grigs

Nov 18 '05 #4
Actually, there is nothing going on in the Page_Load event. Basically, there
is a single edit box and button. You type the number of the Sales Order in
it and click the button. At that point it goes and gathers rows from an
Oracle database and then for each of those rows, checks a MySQL database for
0 or more documents related to the item.

Then this other button, the print button, would simply go through each row.
Problem is, the button apparently does an AutoPostBack and there is no
property to shut that off? So it refreshes the page and lose everything.

I suppose I can create a DataSet from my WebSerivce that is gathering the
data. But will I be able to put a checkbox in there as well? Letting the
user select to print that document or not.

Kevin

"Cowboy (Gregory A. Beamer) - MVP" wrote:
Most likely, you are refreshing the data after you are adding the rows. For
example, adding rows in Page_Load, but getting the data in a button click
event. Step through in the debugger and you will likely see where you are
refreshing.

NOTE that some items are not automagically stored in ViewState, as you would
expect. If the ASP:Table is created by binding to data, you are best to cache
the DataSet (ViewState is fine) and update rows before binding. you can keep
the updated result set in ViewState if you do not want to update the data
source with each row.
---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Grigs" wrote:
Hello,

I have an asp:table on my page. I am, after a button gets clicked,
programmatically adding rows and their cells. Using the Cell.Text = to put
the value in the cell. I then have another button (which will eventually
print form the server) that refreshes the page of course. When the page gets
refreshed, none of my rows of the table (except the static header area)
remain.

I figured it was an .EnableViewState issue so I do a foreach on the
Page.Controls and set it to true. This changes nothing.

How can I dynamically create a table and have it remember upon refresh?

TIA,
Grigs

Nov 18 '05 #5

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

Similar topics

5
by: Billy Cormic | last post by:
Hello, I am interested in dynamically creating temp tables using a variable in MS SQL Server 2000. For example: DECLARE @l_personsUID int select @l_personsUID = 9842
1
by: Jack Black | last post by:
Not even sure where to start on this one... I need to be able to either: a) set up a SPAN around a dynamically-generated table row (using TableRow object), or b) apply an "onmouseover" property...
2
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is...
0
by: spacehopper_man | last post by:
hi - I am writing a "tab" control. - but it's losing the viewstate of the content pane when I switch between tabs. can anyone shed any light on why I'm losing ViewState based on my simple...
2
by: epigram | last post by:
I'm dynamically creating a number of radio buttons on my aspx page based upon data read from a db. Each radio button has autopostback turned on. I'm experiencing two problems. 1) I am reading...
2
by: somaskarthic | last post by:
Hi In my php code , i dynamically created table rows on button click event. Each row contain 3 selectboxes, 7 checkboxes . On each click of these elements i need to submit the form and save the...
1
by: jonpfl | last post by:
All, I am new to javascript and I am having problems dynamically creating rows and setting attributes. The following works on IE7.x but not IE6.x. Is there another way of creating a checkbox...
8
by: BillE | last post by:
When I create a control dynamically and it grows according to the content, the control Height property still returns the original default control height instead of the height after expanding. ...
1
by: vivek kapile | last post by:
Title:Dynamically adding table row with a checkbox using JavaScript Author:Vivek Kapile Email:snipped Language:JavaScript Platform:JavaScript in ASP.net Technology:Used in ASP.net...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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...

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.