protected void BindData(int Cat_ID) { DataTable dtGrid = proCateController.GetCategoryLayoutByCatID(Cat_ID); string selectedProduct = ""; string grid = ""; if (dtGrid != null && dtGrid.Rows.Count > 0) { for (int i = 0; i < dtGrid.Rows.Count && i < 20; i++) { grid += "<div class=\"gridItem\" id=\"container" + (i + 1) + "\">"; if (dtGrid.Rows[i]["ProductID"].ToString() != "0") { selectedProduct += dtGrid.Rows[i]["ProductID"] + ","; grid += " <div class=\"productItem\" data-id=\"" + dtGrid.Rows[i]["ProductID"] + "\"><img src=\"/" + dtGrid.Rows[i]["ProductAvatar"] + "\" style=\"max-height: 60px; max-width: 60px\"/></div> "; } grid += "</div>"; } if (dtGrid.Rows.Count < 20) { for (int i = dtGrid.Rows.Count; i < 20; i++) { grid += "<div class=\"gridItem\" id=\"container" + (i + 1) + "\">"; grid += "</div>"; } } ltrGrid.Text = grid; selectedProduct = selectedProduct.TrimEnd(','); } else { for (int i = 0; i < 20; i++) { grid += "<div class=\"gridItem\" id=\"container" + (i + 1) + "\">"; grid += "</div>"; } ltrGrid.Text = grid; } string where = "ProductCategory = " + Cat_ID; where += !string.IsNullOrEmpty(selectedProduct) ? " and ID not in(" + selectedProduct + ")" : string.Empty; List <Product> dtListProduct = proController.ProductsSelectDynamic(where, ""); // if (dtListProduct != null && dtListProduct.Count > 0) { rptListProduct.DataSource = dtListProduct; rptListProduct.DataBind(); } }