Here is my code.Please let me know where i was going wrong?
TabController controller = new TabController();
newTab = new TabInfo();
newTab.PortalID = PortalId;
newTab.TabName = "OfficeMap";
newTab.Title = "OfficeMap";
newTab.Description = "OfficeMap";
newTab.KeyWords = "Office";
newTab.IsDeleted = false;
newTab.IsSuperTab = false;
newTab.IsVisible = true;
newTab.DisableLink = false;
newTab.IconFile = "";
newTab.Url = "";
newTab.TabPermissions = PermGrid.Permissions;
controller.AddTab(newTab);
DataCache.ClearModuleCache(newTab.TabID);
Response.Redirect(Globals.NavigateURL(TabId));
ModuleController modCtr = new ModuleController();
ModuleInfo modInfo = new ModuleInfo();
modInfo = modCtr.GetModuleByDefinition(PortalSettings.PortalId, "OfficeMap");
newTab = controller.GetTabByName("OfficeMap", this.PortalId);
modInfo.TabID = newTab.TabID; modInfo.ModuleTitle = "OfficeMap";
modInfo.PaneName = "ContentPane"; modCtr.AddModule(modInfo);