Connecting Tech Pros Worldwide Forums | Help | Site Map

Dynamically generated Table Rows Dissappear

Bijoy Naick
Guest
 
Posts: n/a
#1: Nov 18 '05
I have something strange going on.. My .aspx page contains a file upload
control, a "Import Data" button, a "newTransactions" <asp:table>,
a"SaveTrans" button and an confMsg label.

First the user selects a file, then clicks Import Data. The page now reads
the PostedFile and displays each line as a new row in the newTransactions
table. All of this works fine.

For now, I've programmed SaveTrans_Click to display the number of rows in
the newTransactions table in the confMsg label.

When I click on the SaveTrans button, all the rows added dynamically in the
table dissapper and as a result, the congMsg label displays 1 (the header
row I hard coded in the <asp:table> declaration).

What do i need to do to avoid this? Why is this happening?

Thanks.

Bijoy




Jeffrey Palermo [MCP]
Guest
 
Posts: n/a
#2: Nov 18 '05

re: Dynamically generated Table Rows Dissappear


Bijoy,
Understand that dynamic controls have to be created and added to the
page each time the page is built. You are building these table rows in a
post-back event handler, but on the next post-back you aren't building the
rows, so naturally they won't be there after that last post-back. You need
to rethink your page design to make sure that the data for these table rows
can be saved in viewstate and persisted from post-back to post-back.

Best regards,
Jeffrey Palermo

"Bijoy Naick" <b_naick@yahoo.ca> wrote in message
news:OHhxEiJ1EHA.2856@TK2MSFTNGP15.phx.gbl...[color=blue]
> I have something strange going on.. My .aspx page contains a file upload
> control, a "Import Data" button, a "newTransactions" <asp:table>,
> a"SaveTrans" button and an confMsg label.
>
> First the user selects a file, then clicks Import Data. The page now reads
> the PostedFile and displays each line as a new row in the newTransactions
> table. All of this works fine.
>
> For now, I've programmed SaveTrans_Click to display the number of rows in
> the newTransactions table in the confMsg label.
>
> When I click on the SaveTrans button, all the rows added dynamically in[/color]
the[color=blue]
> table dissapper and as a result, the congMsg label displays 1 (the header
> row I hard coded in the <asp:table> declaration).
>
> What do i need to do to avoid this? Why is this happening?
>
> Thanks.
>
> Bijoy
>
>
>[/color]


Bijoy Naick
Guest
 
Posts: n/a
#3: Nov 18 '05

re: Dynamically generated Table Rows Dissappear


I "fixed" this by adding the rows to a Session level variable. I was unable
to add a tablerow to ViewState.. Got an error about it not implementing
"Serializable"..

How can I add a tablerow to viewstate?

Thx.

Bijoy


"Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote in
message news:OMu9sSb1EHA.2876@TK2MSFTNGP12.phx.gbl...[color=blue]
> Bijoy,
> Understand that dynamic controls have to be created and added to the
> page each time the page is built. You are building these table rows in a
> post-back event handler, but on the next post-back you aren't building the
> rows, so naturally they won't be there after that last post-back. You[/color]
need[color=blue]
> to rethink your page design to make sure that the data for these table[/color]
rows[color=blue]
> can be saved in viewstate and persisted from post-back to post-back.
>
> Best regards,
> Jeffrey Palermo
>
> "Bijoy Naick" <b_naick@yahoo.ca> wrote in message
> news:OHhxEiJ1EHA.2856@TK2MSFTNGP15.phx.gbl...[color=green]
> > I have something strange going on.. My .aspx page contains a file upload
> > control, a "Import Data" button, a "newTransactions" <asp:table>,
> > a"SaveTrans" button and an confMsg label.
> >
> > First the user selects a file, then clicks Import Data. The page now[/color][/color]
reads[color=blue][color=green]
> > the PostedFile and displays each line as a new row in the[/color][/color]
newTransactions[color=blue][color=green]
> > table. All of this works fine.
> >
> > For now, I've programmed SaveTrans_Click to display the number of rows[/color][/color]
in[color=blue][color=green]
> > the newTransactions table in the confMsg label.
> >
> > When I click on the SaveTrans button, all the rows added dynamically in[/color]
> the[color=green]
> > table dissapper and as a result, the congMsg label displays 1 (the[/color][/color]
header[color=blue][color=green]
> > row I hard coded in the <asp:table> declaration).
> >
> > What do i need to do to avoid this? Why is this happening?
> >
> > Thanks.
> >
> > Bijoy
> >
> >
> >[/color]
>
>[/color]


Jeffrey Palermo [MCP]
Guest
 
Posts: n/a
#4: Nov 18 '05

re: Dynamically generated Table Rows Dissappear


Bijoy,
You cannot add objects to viewstate that are not serializable. The
objects that are stored in viewstate can be represented as a string.
TableRow is not one of these. You can store the data for the row in
viewstate, but not the control itself.

--
Best regards,
Jeffrey Palermo
Blog: http://dotnetjunkies.com/weblog/jpalermo


"Bijoy Naick" <b_naick@yahoo.ca> wrote in message
news:OaW1aWi1EHA.412@TK2MSFTNGP14.phx.gbl...[color=blue]
> I "fixed" this by adding the rows to a Session level variable. I was[/color]
unable[color=blue]
> to add a tablerow to ViewState.. Got an error about it not implementing
> "Serializable"..
>
> How can I add a tablerow to viewstate?
>
> Thx.
>
> Bijoy
>
>
> "Jeffrey Palermo [MCP]" <http://dotnetjunkies.com/weblog/jpalermo> wrote[/color]
in[color=blue]
> message news:OMu9sSb1EHA.2876@TK2MSFTNGP12.phx.gbl...[color=green]
> > Bijoy,
> > Understand that dynamic controls have to be created and added to the
> > page each time the page is built. You are building these table rows in[/color][/color]
a[color=blue][color=green]
> > post-back event handler, but on the next post-back you aren't building[/color][/color]
the[color=blue][color=green]
> > rows, so naturally they won't be there after that last post-back. You[/color]
> need[color=green]
> > to rethink your page design to make sure that the data for these table[/color]
> rows[color=green]
> > can be saved in viewstate and persisted from post-back to post-back.
> >
> > Best regards,
> > Jeffrey Palermo
> >
> > "Bijoy Naick" <b_naick@yahoo.ca> wrote in message
> > news:OHhxEiJ1EHA.2856@TK2MSFTNGP15.phx.gbl...[color=darkred]
> > > I have something strange going on.. My .aspx page contains a file[/color][/color][/color]
upload[color=blue][color=green][color=darkred]
> > > control, a "Import Data" button, a "newTransactions" <asp:table>,
> > > a"SaveTrans" button and an confMsg label.
> > >
> > > First the user selects a file, then clicks Import Data. The page now[/color][/color]
> reads[color=green][color=darkred]
> > > the PostedFile and displays each line as a new row in the[/color][/color]
> newTransactions[color=green][color=darkred]
> > > table. All of this works fine.
> > >
> > > For now, I've programmed SaveTrans_Click to display the number of rows[/color][/color]
> in[color=green][color=darkred]
> > > the newTransactions table in the confMsg label.
> > >
> > > When I click on the SaveTrans button, all the rows added dynamically[/color][/color][/color]
in[color=blue][color=green]
> > the[color=darkred]
> > > table dissapper and as a result, the congMsg label displays 1 (the[/color][/color]
> header[color=green][color=darkred]
> > > row I hard coded in the <asp:table> declaration).
> > >
> > > What do i need to do to avoid this? Why is this happening?
> > >
> > > Thanks.
> > >
> > > Bijoy
> > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]


Closed Thread