asp:repeater not doing a refresh/postback

S

Scott Lyon

I am having a strange problem. The program is a bit complex, but I'll try to
simplify what I can. I apologize if this is complicated, but I think this
would still be simpler than posting a bunch of source code. If you want me
to post code, though, just say so.


In a nutshell, I've got an ASP.NET application that has one main ASPX page.
On that ASPX page, it has a user control (an ASCX) that displays the actual
data and controls I need.


On that user control, I have a drop-down list, and an asp:repeater tag that
contains an asp:label tag that contains:
<%# DataBinder.Eval(Container.DataItem, "DESC") %> as the Text= field

That asp:repeater also contains an asp:imagebutton that is a "Delete"
button.


Basically, when the user makes a selection from the drop-down list, a stored
procedure is called, and that data populates the asp:repeater (adding an
entry for each row retrieved by the stored procedure).


This part works fine.

The way it's set up, if the user clicks the "Delete" button after this has
been populated, it removes that entry from the database (which works
correctly), and then calls the code again to repopulate the repeater.


I've confirmed that this seems to work (the row does get deleted, and when
the stored procedure is called, it returns the proper rows, without the
"deleted" entry). But it does not appear to be refreshing the repeater. The
repeater (in some cases) remains with the additional row still showing, and
in other cases, blanks out entirely.


The code I use to populate is a function that calls the stored procedure,
and returns it in a DataTable. Then that DataTable is set up as the
DataSource of the repeater, and then does a .DataBind on it as well.


What am I missing? It seems to me that I need to force a refresh or postback
or something. But I'm at a loss to figure out how to do that.


Can anyone help?


Thanks!
 
L

L. L.

Scott,

When the user clicks on the Delete button, the page will post back and call
the sp to delete the record. Apparently this part worked as you described.
However, after deleting the record, you need create the DataTable again and
bind it to the grid. That will force the repeater to refresh.

L.L.
 
S

Scott Lyon

That's exactly what I'm doing.


In the module that does the delete, first it does the database call to
delete the row. Then it does the database call to re-populate the repeater
grid (and put that into the DataTable). Then it sets that DataTable to the
source of the grid, and then binds the data.

In fact, I've even stepped it through the code, and I saw it step right
through each step as expected.


But oddly enough, it still never refreshed the grid on the form.


Thanks!
-Scott
 
L

L. L.

What about try the following,
After the row is deleted, close the browser. Double check to make sure the
row is actually deleted in the db. And then open the browser again to view
the page. If the row deleted is still in the data grid, the only thing I can
think of is caching. Maybe the page or user control is being cached.

L.L.
 
S

Scott Lyon

I have been able to confirm that the delete is actually happening on the
database. In fact, if I make another selection from the drop-down list (with
autopostback enabled), and then switch back to the original selection, it
shows exactly what it should (all the rows there previously, except for the
one deleted is gone).


Is there a way I can either force the postback (in ASP.NET), or somehow
prevent it from being cached in that way?


Thanks!
-Scott
 

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,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top