C# - Dynamically Creating Table - Losing ViewState

G

Guest

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
 
G

Guest

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

Vinay
 
G

Guest

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
 
G

Guest

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!
***************************
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top