Static user control disappears after postback

S

Svetoslav Vasilev

Hi, I have recently come across a subtle behavior of ASP.NET 2.0 user
controls, for which i cannot find the cause and therefore need som help. I
have the following scenario - i need to show one grid view where I can select
individual rows, which are displayed in a second grid upon selection. From
the second grid i have the ability to remove rows individually.
I have developed this as follows - user control A.ascx containing a grid
view and the logic for handling the events fired by it - both select and
remove. It exposes public events that are fired upon corresponding event from
the grid view, so that other controls & pages can be notified if needed. In
another control - B.ascx i have defined 2 instances of the control A through
markup - each with its own ID. The strange behaviour is expressed in that
when I select a row from the first grid, the SelectedIndexChanged is properly
fired, the corresponding logic properly executed, but when the page is
rendered, the first grid disappears and only the second with the selected
rows is shown. If I then try to remove one row from the second grid, the
event fires correctly and the logic executes properly, but the page is
rendered without no grids.
In a breakpoint in the SelectedIndexchanged I noticed that the DataKeys
collection is properly populated, but the Rows collection is empty.
Have anyone experienced similar behaviour and if so, please let me know how
to solve it.
Many thanks in advance!
Svetoslav
 

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,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top