Monday, March 26, 2012

Tab Control is throwing an exception on postback

I have a tab container control on my page located within a view. When the view is activated I do a query and dynamically add the tabs based on a query like so:

 DataTable tblCollAttrs = oBAL.GetCollectionAttrs(DetailItemID);foreach(DataRow drowin tblCollAttrs.Rows) { TabPanel collTabPnl =new TabPanel(); collTabPnl.HeaderText = drow["vchAttributeName"].ToString(); relTablContainer.Tabs.Add(collTabPnl); }

So far everything is fine. Now I click an unrelated button which does a full postback that switches the view and I get this exception:Specified argument was out of the range of valid values. Here is where it is crashing in TabPanelCollection.cs:

public new TabPanel this[int index]
{
: get { return (TabPanel)base[index]; }
}

What am I missing here?

Unfortunately, the tab control does not play nice with dynamically added tabs. It does not re-create them during pre-init, and when it goes to set the active tab, you get the error you are seeing because the active tab index is greater than the number of tabs.


Is there anyway around this?


HiI have also this problem.please help me.

Because of this limitation I was unable to use this AJAX control. I ended up creating my own TabStrip control and putting it in an UpdatePanel.

Sorry I don't have a better response.

No comments:

Post a Comment