private void UpdateDataView() { string sSql = string.Empty; string filter = txtFilter.Text; if (filter != string.Empty) { string cleanFilter = filter.Replace("'", "''").ToLower(); cleanFilter = cleanFilter.Replace("[", "[[]"); cleanFilter = cleanFilter.Replace("_", "[_]"); cleanFilter = cleanFilter.Replace("%", "[%]"); sSql = " LOWER(ItemTypeName) like '%" + cleanFilter + "%' "; } using (ItemTypeList itemTypes = ItemType.GetAll(sSql)) { if (itemTypes != null) { if (itemTypes.Count > 0) { dg.DataSource = itemTypes; Utils.InitGridSort(ref dg); dg.DataBind(); dg.Visible = true; lbNoresults.Visible = false; } else { if (txtFilter.Text.Length > 0) { lbNoresults.Text = "No record match your search (" + txtFilter.Text + ")"; } lbNoresults.Visible = true; dg.Visible = false; } } } panelGrid.Visible = true; lbTitle.Text = "Item types list"; }