User Control Not Updating

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

Hi,
using vb.net/vs 2003/sql server 2000

Working on a shopping cart app. I've got a user control that appears on
every page to give a summary of the users shopping cart, eg You have 12
items in your cart, the total is £123.45, this is populated with a stored
procedure that just returns itemcount and itemtotal as output params. This
works fine. On the shopping cart page itself I use a datagrid to list out
the users cart contents and allow him to update quantity or delete an item
from the cart(set quantity to 0). However when a user updates the cart the
user control does not update to reflect the new quantities until either
going to another page or reloading the cart page. It seems that what I need
is something like
if cart has been updated then
refresh the user control

Any suggestions? I'm very new to asp.net - obviously :-)

Cheers,
Jon
 
Hi, Jon,

If you have a reference to the usercontrol and you can access this reference
in the method that updates the cart then use this reference to call some
method that will update the usercontrol.

Something like (the class of the page that updates the cart):

//the reference:
protected CartDisplayUserControl control1;

//the event handler for the "Update" button
protected void HandleUpdateClick(object s, EventArgs e)
{
// process here...

// force the control to refresh:
control1.SomeMethodThatRefreshesIt();
}

Greetings
Martin
 
Back
Top