how to refresh screen after delete a record

  • Thread starter Thread starter J
  • Start date Start date
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.
 
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
 
Back
Top