public static string CreateMenuFromDT(DataTable dt)
{
string retstring = "";
DataRow[] drparentMain = dt.Select("ParentID =0 OR ParentID is null");
foreach (DataRow dr in drparentMain)
{
string strmenuselect = Convert.ToString(dr["selected"]) == "0" ? "menu_nonselected" : "menu_selected";
string strsubmenu = "";
DataRow[] drparentMenu = dt.Select("ParentID =" + Convert.ToString(dr["MenuID"]));
foreach (DataRow pdr in drparentMenu)
{
if (!string.IsNullOrEmpty(strsubmenu))
strsubmenu = " <div class='submenu_straight'><ul><li><a href='" + Convert.ToString(pdr["navigateurl"]) + "' class='parent'><p>" + Convert.ToString(pdr["Text"]) + "</p></a></li>";
else
strsubmenu = strsubmenu + "<li><a href='" + Convert.ToString(pdr["navigateurl"]) + "' class='parent'><p>" + Convert.ToString(pdr["Text"]) + "</p></a></li>";
}
if (!string.IsNullOrEmpty(strsubmenu))
strsubmenu = strsubmenu + "</ul></div>";
if (string.IsNullOrEmpty(retstring))
retstring = "<li class='" + strmenuselect + "'><p><a href='" + Convert.ToString(dr["navigateurl"]) + "'>" + Convert.ToString(dr["Text"]) + "</a></p>" + strsubmenu + "</li>";
else
retstring = retstring + "<li class='" + strmenuselect + "'><p><a href='" + Convert.ToString(dr["navigateurl"]) + "'>" + Convert.ToString(dr["Text"]) + "</a></p>" + strsubmenu + "</li>";
}
return retstring;
}
{
string retstring = "";
DataRow[] drparentMain = dt.Select("ParentID =0 OR ParentID is null");
foreach (DataRow dr in drparentMain)
{
string strmenuselect = Convert.ToString(dr["selected"]) == "0" ? "menu_nonselected" : "menu_selected";
string strsubmenu = "";
DataRow[] drparentMenu = dt.Select("ParentID =" + Convert.ToString(dr["MenuID"]));
foreach (DataRow pdr in drparentMenu)
{
if (!string.IsNullOrEmpty(strsubmenu))
strsubmenu = " <div class='submenu_straight'><ul><li><a href='" + Convert.ToString(pdr["navigateurl"]) + "' class='parent'><p>" + Convert.ToString(pdr["Text"]) + "</p></a></li>";
else
strsubmenu = strsubmenu + "<li><a href='" + Convert.ToString(pdr["navigateurl"]) + "' class='parent'><p>" + Convert.ToString(pdr["Text"]) + "</p></a></li>";
}
if (!string.IsNullOrEmpty(strsubmenu))
strsubmenu = strsubmenu + "</ul></div>";
if (string.IsNullOrEmpty(retstring))
retstring = "<li class='" + strmenuselect + "'><p><a href='" + Convert.ToString(dr["navigateurl"]) + "'>" + Convert.ToString(dr["Text"]) + "</a></p>" + strsubmenu + "</li>";
else
retstring = retstring + "<li class='" + strmenuselect + "'><p><a href='" + Convert.ToString(dr["navigateurl"]) + "'>" + Convert.ToString(dr["Text"]) + "</a></p>" + strsubmenu + "</li>";
}
return retstring;
}
No comments:
Post a Comment