Forums - C# Corner

Forum guidelines
jorge graur

jorge graur

  • 1.6k
  • 1
  • 270

mvc 4 asp runtime menu building problem

Jul 31 2017 10:49 AM
I am iniciate in mvc4, and need help.
my code is
    For Each dr As Data.DataRow In ViewBag.MenuList.rows
    Dim mm As String = dr.Item(2).ToString
  • @Html.ActionLink(mm, "#", "#")
  • @:
      For Each drCat As Data.DataRow In ViewBag.getSubMenu(mm).rows <- problem is hear
    • @Html.ActionLink(drCat.Item(2).ToString, "#", "#")
    • Next
      End code
      Controller :
      Function getSubMenu(ByVal sMenu As String) As ActionResult
      'cCon = New SqlConnection(sCon)
      Dim subMenuCatList As New clsCategorias
      subMenuCatList.cConn = cCon
      subMenuCatList.MenuStr = sMenu
      Dim dsCat As DataSet = subMenuCatList.GetListCategories()
      ViewBag.MenuList = dsCat.Tables(0)
      Dim a As New List(Of String)
      For Each el As DataRow In dsCat.Tables(0).Rows
      a.Add(el(0) & ";" & el(2))
      Session("myMenuCatList") = a
      Return View(a)
      Catch ex As Exception
      Throw ex
      End Try
      I am trying to build the menu in "runtime", the first level of the menu is being returned well, but when I am passing a parameter to fill the second level of the menu the system gives an error. I think the problem is in passing the parameter. Can someone help?

      Answers (1)