ColorlibHQ / AdminLTE

AdminLTE - Free admin dashboard template based on Bootstrap 5
https://adminlte.io
MIT License
43.92k stars 18.17k forks source link

AdminLTE Error while binding via database driven from mysql #1744

Closed sathishpsy89 closed 6 years ago

sathishpsy89 commented 6 years ago

Hi,

I am happy that i can fetch data from database and load in AdminLTE ( version 2.3.2 & 2.4.0)menu. but i got error while collapsing the menu by clicking the toggle button.

menuerror

menuerror2

almasaeed2010 commented 6 years ago

Please make sure that your HTML markup is correct.

Thanks!

sathishpsy89 commented 6 years ago

Hi, I had tried out in many scenarios and i have attached the code where i implemented,kindly correct the code if there is any wrong in my code.

Master1.Master [Master Page in asp.net]:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Master1.master.cs" Inherits="DML_EHRM.Master.Master1" %>

<!DOCTYPE html>

Year Master 2017 - 2018

-------------------End Of Html Tag

Master1.Master.cs page

protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.BindMenu();

        }
    }

    protected void rptMenu_OnItemBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            Repeater rptSubMenu = e.Item.FindControl("rptChildMenu") as Repeater;
            rptSubMenu.DataSource = UDF.FillDataTable("SELECT Parent_Child_ID,Menu_Name,Menu_Url,Menu_Icon FROM dml_menu_setting WHERE Parent_Child_ID =" + ((System.Data.DataRowView)(e.Item.DataItem)).Row[0], false);
            rptSubMenu.DataBind();
        }
    }

    private void BindMenu()
    {
        this.rptMenu.DataSource = UDF.FillDataTable("SELECT Menu_ID, Parent_Child_ID, Menu_Name, Menu_Description, Menu_Url,Menu_Icon FROM dml_menu_setting WHERE Menu_Status=1 AND Parent_Child_Id = 0", false);
        this.rptMenu.DataBind();
    }
sathishpsy89 commented 6 years ago

Is there any update regarding this issue

REJack commented 6 years ago
  1. learn to use Github, use a real code block for better code display, it's way to hard to check these lines.

  2. Change your aspRepeater#rptMenu ItemTemplate to this

    <ul class="sidebar-menu">
    <li class="treeview">
    <a href='<%#Eval("Menu_Url") %>'>
      <i class='<%#Eval("Menu_Icon") %>'></i>
      <span><%#Eval("Menu_Name") %></span>
      <ul class="treeview-menu">
        <asp:Repeater ID="rptChildMenu" runat="server">
          <ItemTemplate>
            <li><a href="Master/DD1.aspx"><i class='<%#Eval("Menu_Icon") %>'></i><%#Eval("Menu_Name") %></a></li>
          </ItemTemplate>
        </asp:Repeater>
      </ul>
    </a>
    </li>
    </ul>                                 

    You missed the span around your Menu_Name.

This is still not perfect but should work, in my opinion you should not repeat to much the <ul class="sidebar-menu"> I would place the repeat without the ul and try also to add only class="treeview" if rptChildMenu is filled & if rptChildMenu is not filled don't display class="treeview" otherwise you can't use the link.

sathishpsy89 commented 6 years ago

Hi Alma Saeed, It's working, Thansk Alma saeed.

On Nov 29, 2017 5:06 PM, "Raphael Jackstadt" notifications@github.com wrote:

1.

learn to use Github, use a real code block https://help.github.com/articles/creating-and-highlighting-code-blocks/ for better code display, it's way to hard to check these lines. 2.

Change your aspRepeater#rptMenu ItemTemplate to this

You missed the span around your Menu_Name.

This is still not perfect but should work, in my opinion you should not repeat to much the