jorge graur

jorge graur

  • NA
  • 62
  • 651

mvc 4 asp vb.net runtime menu building problem

Jul 31 2017 10:49 AM
 Hi.
I am iniciate in mvc4, and need help.
my code is
 
    @Code
    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
      @:
      @:
      Next
      End code
       
      Controller :
       
       
      Function getSubMenu(ByVal sMenu As String) As ActionResult
      Try
      'cCon = New SqlConnection(sCon)
      'cCon.Open()
      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))
      Next
      Session("myMenuCatList") = a
      Return View(a)
      Catch ex As Exception
      Throw ex
      Finally
      cCon.Close()
      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?
       
      Thancks 
       
       

      Answers (1)