private void renderHTML(DataTable dt, string view = "1") { StringBuilder html = new StringBuilder(); if (dt.Rows.Count > 0) { pnControl.Visible = true; foreach (DataRow row in dt.Rows) { CultureInfo cul = CultureInfo.GetCultureInfo("vi-VN"); // try with "en-US" string tien = double.Parse(row["price"].ToString()).ToString("#,### VNĐ", cul.NumberFormat); string image_link = ""; //getImagesByIdProduct if (dt.Columns.Contains("link_image")) { image_link = row["link_image"].ToString(); } else { ConnectDB dbConnect = new ConnectDB(); DataTable dtImages = dbConnect.getImagesByIdProduct(Convert.ToInt32(row["id_product"])); if (dtImages.Rows.Count >= 1) { image_link = dtImages.Rows[0]["link_image"].ToString(); } } string id_product = row["id_product"].ToString(); if (view == "1") { html.Append("<div class='coDownProduct'><div class='productGrid'><div class='countDown' data-end='kmdn_ngay1_thang12_nam2017'>208D : 12H : 38M : 10S</div><div class='productImg'>"); html.Append("<a href='#' title='" + row["name"] + "'><img src='" + image_link + "' data-original='" + image_link + "' class='img-fix' alt='" + row["name"] + "' style='display: inline;'></a>"); html.Append("<div class='hoverButtons'>"); html.Append("<span data-toggle='modal' data-target='Cart.aspx?action=add&id=" + id_product + "'><a href='Cart.aspx?action=add&id=" + id_product + "' class='button quickview-btn' data-toggle='tooltip' data-placement='top' title='' data-countdown='null' data-alias='may-giat-panasonic-10-kg-na-f100a1wrv' data-original-title='Cho vào giỏ hàng'><i class='fa fa-shopping-cart'></i></a></span>"); html.Append("<span data-toggle='modal' data-target='ProductDetail.aspx?id=" + id_product + "'><a href='ProductDetail.aspx?id=" + id_product + "' class='button quickview-btn' data-toggle='tooltip' data-placement='top' title='' data-countdown='null' data-alias='may-giat-panasonic-10-kg-na-f100a1wrv' data-original-title='Xem nhanh'><i class='fa fa-search'></i></a></span>"); html.Append("<a href='#' class='button skype' data-toggle='tooltip' data-placement='top' title='' data-original-title='Tư vấn qua Skype'><i class='fa fa-skype'></i></a>"); html.Append("</div></div><h3><a href='ProductDetail.aspx?id=" + id_product + "' title='" + row["name"] + "'>" + row["name"] + "</a></h3>"); html.Append("<div class='productPrice'><span>" + tien + "</span></div></div></div>"); } else { html.Append("<div class='item-2'><div class='productList QuickAddToCart clearfix'><div class='productListImg'>"); html.Append("<a href='#'><img src='" + image_link + "' data-original='" + image_link + "' class='img-responsive lazy imgQuickAddToCart' alt='" + row["name"] + "'></a></div>"); html.Append("<div class='productListInfo'>"); html.Append("<h3><a href='#'>" + row["name"] + "</a></h3>"); html.Append("<div class='productListPrice priceQuickAddToCart'><span>" + tien + "</span></div>"); html.Append("<span class='line'></span>"); html.Append("<div class='productListDesc'>" + row["description"] + "</div>"); html.Append("<div class='formQuickAddToCart productListForm'>"); html.Append("<input type='hidden' name='variantId' value='9363959'>"); html.Append("<a href='Cart.aspx?action=add&id=" + id_product + "' class='button buttonProductList quickAddToCart' data-toggle='tooltip' title='' data-original-title='Cho vào giỏ hàng'><i class='fa fa-shopping-cart'></i> Cho vào giỏ hàng</button>"); html.Append("<a href='#' class='button skype' data-toggle='tooltip' title='' data-original-title='Chat qua Skype'><i class='fa fa-skype'></i></a></div></div></div></div>"); } } } else { pnControl.Visible = false; html.Append("<h2 style='text-align:center;margin: 40px auto;font-size: 2em;'>Không có sản phẩm nào được hiển thị :(</h2>"); } grdContent.Controls.Add(new Literal { Text = "" }); grdContent.Controls.Add(new Literal { Text = html.ToString() }); }
protected void loadLeftMenu() { ConnectDB dbGroupCat = new ConnectDB(); DataTable dtGroupCats = dbGroupCat.getAllGroupCategories(); ConnectDB dbCats = new ConnectDB(); DataTable dtCats = dbCats.getAllCategories(); StringBuilder html = new StringBuilder(); int subMenu = 1; foreach (DataRow gCat in dtGroupCats.Rows) { html.Append("<li class='has-sub panel'>"); html.Append("<a href='Search.aspx?group_cat=" + gCat["id_group_category"] + "'>" + gCat["name"] + "</a><em data-parent='#sub-menu-product' data-target='#sub-sub-menu-" + subMenu.ToString() + "' data-toggle='collapse' class='collapsed'><i class='fa fa-angle-down'></i></em>"); html.Append("<ul class='list-unstyled collapse' id='sub-sub-menu-" + subMenu.ToString() + "'>"); foreach (DataRow cat in dtCats.Rows) { if (cat["id_group"].ToString() == gCat["id_group_category"].ToString()) { html.Append("<li><a href='Search.aspx?group_cat=" + gCat["id_group_category"] + "&cat=" + cat["id_category"] + "'>" + cat["category"] + "</a></li>"); } } html.Append("</ul></li>"); subMenu++; } liContent.Controls.Add(new Literal { Text = html.ToString() }); html.Clear(); // Load megaMenu int count = 0; foreach (DataRow gCat in dtGroupCats.Rows) { html.Append("<div class='col-md-4'>"); html.Append("<h2 class='titleDecoration'><span class='line'></span><a href='Search.aspx?group_cat=" + gCat["id_group_category"] + "' class='title'>" + gCat["name"] + "</a></h2>"); html.Append("<ul class='list-unstyled listMenu'>"); foreach (DataRow cat in dtCats.Rows) { if (cat["id_group"].ToString() == gCat["id_group_category"].ToString()) { html.Append("<li><a href='Search.aspx?group_cat=" + gCat["id_group_category"] + "&cat=" + cat["id_category"] + "'>" + cat["category"] + "</a></li>"); } } html.Append("</ul></div>"); count++; if (count >= 3) { html.Append("<div class='clearfix'></div>"); count = 0; } } megaMenuContent.Controls.Add(new Literal { Text = html.ToString() }); html.Clear(); // Load mobile menu subMenu = 1; foreach (DataRow gCat in dtGroupCats.Rows) { html.Append("<li class='hasSubListCate panel'>"); html.Append("<a href='Search.aspx?group_cat=" + gCat["id_group_category"] + "'>" + gCat["name"] + "</a><em data-parent='#panel-mobile-menu' class='collapsed' data-toggle='collapse' data-target='#sub-menu-" + subMenu.ToString() + "'><i class='fa fa-angle-down'></i></em>"); html.Append("<ul class='list-unstyled SubListCate collapse' id='sub-menu-" + subMenu.ToString() + "'>"); foreach (DataRow cat in dtCats.Rows) { if (cat["id_group"].ToString() == gCat["id_group_category"].ToString()) { html.Append("<li><a href='Search.aspx?group_cat=" + gCat["id_group_category"] + "&cat=" + cat["id_category"] + "'>" + cat["category"] + "</a></li>"); } } html.Append("</ul></li>"); subMenu++; } mobileMenuContent.Controls.Add(new Literal { Text = html.ToString() }); }