Databound control displays old data

E

Eric Maia

I have an ASP.Net page with a Repeater that displays a list of
records. These records have "delete" links which redirect to a
separate page for confirmation and delete the record. When the
deletion is complete, the browser is redirected back to the list page.

When I delete a record and get returned to the list page, the Repeater
still shows the deleted record. If I refresh the list page, the
correct data (without the deleted record) is shown. In other words,
I'm being redirected back, but the page is not being reloaded - the
old page is shown.

I have 4 or five of these list pages with databound Repeaters, and
they all show the same behavior.

Why would using Response.Redirect() from one page (e.g.
TypeDelete.aspx) to another (e.g. TypeList.aspx) not cause Page_Load()
to run and query and load new data into the Repeater?

Thanks - Eric
 
G

Guest

Hi Eric
I guess the page_load is invoked.. Check the ispostback property When the
page is redirected.. or may be the page is cached on the local browser..Try
setting the
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);

so that the page is not cached..

Hope this helps
 
E

Eric Maia

Thanks, I tried using
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
in the Page_Load method, and it does not have any effect. I still have
to manually refresh the page for deleted records to disappear.

The strange thing is, it only displays this behavior with deletes. If
I edit a record, the new text is displayed as soon as I'm returned to
the list of records. If I add a new record, it shows up right away.

Thanks - Eric Maia
 
E

Eric Maia

OK, I figured out why the deleted records were still showing up in my
repeater - stupid error on my part. I forgot to call the Close()
method to close the connection after deleting the record. So,
apparently the database would mark the record for delete but not
commit the deletion right away. I added calls to my Close() method to
all of my delete pages and it works fine now.

(I hope this little confession will help someone else who's made this
error... it's such a basic mistake that I couldn't find it as a
recommended solution anywhere!)

- Eric
 

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,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top