Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
25
manually added group been duplicated after call back and rebuild
posted

Hi

I'm manually filling a webExplorerBar, and it draws perfectly, the user can remove some items on the explorer bar by pressing a button, when this happens i want to redraw the ExplorerBar to show the new items but i got the Groups been duplicated and the new duplacated group show no visual style

I call this code the first time the ExplorerBar is shown and also when i need to refresh it.

webOpciones.Groups.Clear()

For Each drGrupo As DataRow In OpcionesUsuario.dtGrupos.Rows

 oGrupo = New ExplorerBarGroup(drGrupo("GroupName"), drGrupo("id_Group"))
 webOpciones.Groups.Add(oGrupo)

 For Each drOpcion As DataRowView In dvOpciones
  New ExplorerBarItem(drOpcion("Name"), "", drOpcion("URL"), drOpcion("Image"))

  lOpcion = lOpcion.DataItem = drOpcion

  oGrupo.Items.Add(lOpcion)
 Next
Next

Regards.

 

  • 3726
    Suggested Answer
    posted

    Hi,

    one what stage of the page lifecycle you execute this code? If you do it before LoadViewState is done, then the groups will be indeed duplicated.

    Also as I look at the code I think that the first block where you populate the groups should not be called on postback. You should have if(!IsPostback) and then load the groups from the Rows.

    Because once the explorer bar is loaded with data it preserve is in the view state. And when you do a postback(in case of a button click) there is no need to load the whole explorer bar again.

    Thanks,

    Lubomir