Add a new row dynamically to a table

H

Henke

Hello,

I have created a dynamic webcontrol table with several rows. I also have a
ImageButton which
adds a new row to the table. After I have added a new row, and I click the
ImageButton again
I get: "Multiple controls with id '_ctl0' was found ..."

This is what I have done:

page_init:

Check if the table is persisted in a Session variable, if it is then
add it to a placeholder control.

page_load:

If not postback then get the data and render the table and save it
to a Session variable. The Session variable is used in the page_init method
to re-create the dynamic table

I always initialize the imagebutton and adds the eventhandler for the
ImageBtton_onClick.

The error message appers after the page_init method has executed.

I don´t set any ID on the controls in the cells or rows. I let ASP.NET
handle that for me.

Can someone give me any pointers or hints what might be wrong ?

Regards,

// Henke
 
J

Jos

Henke said:
Hello,

I have created a dynamic webcontrol table with several rows. I also
have a ImageButton which
adds a new row to the table. After I have added a new row, and I
click the ImageButton again
I get: "Multiple controls with id '_ctl0' was found ..."

This is what I have done:

page_init:

Check if the table is persisted in a Session variable, if it is then
add it to a placeholder control.

page_load:

If not postback then get the data and render the table and save it
to a Session variable. The Session variable is used in the page_init
method to re-create the dynamic table

I always initialize the imagebutton and adds the eventhandler for the
ImageBtton_onClick.

The error message appers after the page_init method has executed.

I don´t set any ID on the controls in the cells or rows. I let ASP.NET
handle that for me.

Can someone give me any pointers or hints what might be wrong ?

Regards,

// Henke

I guess the error is caused by the recreation from Session.
As a general rule, you should not use Session to persist your table, but
Viewstate.
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top