how to refresh screen after delete a record

J

J

Hi, all
I have a simple question but have no clue how to do this:
I have a datagrid in a web form which presents each user's info, after admin
selected a user, then click 'delete' button, that user will removed from backend
database. Now, how can I have screen refresh to display updated data?

Thanks in advance.
 
K

Karl Seguin

When the button is clicked, and the codebehind event fires, let's call it
"MyGrid_OnItemCommand", you need to rebind your datagrid..since you didn't
give us your existing code, this will hopefully give you an idea:


sub page_load
if not Page.IsPostBack then
BindUserGrid()
end if
end sub

private sub MyGrid_OnItemCommand(s as object, e as DataGridCommandEventArg)
select e.CommandName.ToUpper()
case "DELETE"
UserUtility.DeleteUser(Convert.ToInt32(e.CommandArgument)) 'delete
the user from the backend database
BindUserGrid(); //rebinds the grid
end select
end sub

private sub BindUserGrid()
MyGrid.DataSource = UserUtility.GetAllUsers() //gets the user
MyGrid.DataBind()
end sub


If GetAllUsers was returning a cached result, you'd need to invalidate the
cache. the best place to do this, in the above code anyways, is in the
UserUtility.DeleteUser function

Karl
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top