c1menu add items dynamically

Posted by: marlonschreiber on 10 September 2017, 11:44 am EST

  • Posted 10 September 2017, 11:44 am EST

    Hi I add Items to a c1menu with following code in the page_load event

    Sub Load_Groups(ByVal con As SqlConnection)
    Dim stGROUP As String = "select [GROUP] from mytable"
    Dim da As SqlDataAdapter = New SqlDataAdapter(stGROUP, con)
    Dim ds As DataSet = New DataSet
    da.Fill(ds, "GROUPS")
    If ds.Tables("GROUPS").Rows.Count > 0 Then
    Dim root As C1.Web.Wijmo.Controls.C1Menu.C1MenuItem = C1Menu2.Items(2)
    For Each dr As DataRow In ds.Tables("GROUPS").Rows
    Dim menu As C1.Web.Wijmo.Controls.C1Menu.C1MenuItem = New C1.Web.Wijmo.Controls.C1Menu.C1MenuItem
    menu.Text = dr.Item("GROUP").ToString
    menu.ID = "menue" & dr.Item("GROUP").ToString
    root.Items.Add(menu)
    Next
    End If
    End Sub

    This works! But after I click on one of the new items i get the same items again and again?
    How can I prevent this?
  • Replied 10 September 2017, 11:44 am EST

    put your code under the following :

    If Not IsPostBack Then

    End If


    This will prevent the Items from loading again and again on every postback.

    Regards
  • Replied 10 September 2017, 11:44 am EST

    Thanks Abdias,
    thats it..... Thank You!
  • Replied 10 September 2017, 11:44 am EST

    How do I add a handler that fires onclick for my new items??
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels