Hey!
I want to remove the PageView of a tab and give the tab a new PageView. Currently I'm doing it like this:
// Delete PageView from tab
RadTab tabToReset = TabStripBookings.FindTab(t => Convert.ToInt32(t.Attributes[
"bookingId"
]) == bookingId);
if
(tabToReset ==
null
)
{
System.Diagnostics.Debug.WriteLine($
"Tab with booking id {bookingId} not found."
);
return
;
}
// Remove old PageView
MultiPageBookings.PageViews.Remove(tabToReset.PageView);
// Add new PageView to tab
AddPageView(tabToReset);
The "AddPageView" Method looks like this:
RadPageView pageView =
new
RadPageView();
pageView.ID =
"PageView_"
+ tab.Attributes[
"bookingId"
] ;
// set the id of the pageview depending on the booking ID (0 for new booking)
pageView.CssClass =
"contentWrapper"
+ tab.Index;
pageView.Attributes.Add(
"bookingId"
, tab.Attributes[
"bookingId"
]);
pageView.Attributes.Add(
"day"
, tab.Attributes[
"day"
]);
tab.PageViewID = pageView.ID;
MultiPageBookings.PageViews.Add(pageView);
And finally my PageViewCreated Event:
BookingControl userControl = (BookingControl) Page.LoadControl(
"BookingControl.ascx"
);
// PageView ID is: PageView_BookingId -> split in PageView & BookingId
// Set UserControl id to UserControl_BookingId
userControl.ID =
"UserControl_"
+ e.PageView.ID.ToString().Split(
'_'
)[1];
userControl.BookingDeleted += UserControl_BookingDeleted;
// Subscribe to event when a booking is deleted
userControl.FormReset += UserControl_FormReset;
// Subscribe to event when the form shall be reseted
if
(e.PageView.HasAttributes)
{
userControl.ValuesSet =
true
;
userControl.BookingId = Convert.ToInt32(e.PageView.Attributes[
"bookingId"
]);
userControl.SelectedDay = DateTime.ParseExact(e.PageView.Attributes[
"day"
],
"dd.MM.yyyy"
,
null
);
}
e.PageView.Controls.Add(userControl);
How it shall work:
The first method is called via an event. The MultiPage should be removed and a new one (basically the same one as before, but freshly initialized from the database) is added to the MultiPage.
What it actually does:
At first I don't see the new Tab where it should be. Instead the content of the next tab is shown, but when I switch to another tab and then switch back, the correct PageView is shown.
Is there any solution for this problem? Am I missing something? Can I maybe tell the TabStrip to reload its PageView?
Greetings
Felix