// Handles image src logic protected string RenderImage(object sku) { ProductsDataSource.SelectParameters[0].DefaultValue = sku.ToString(); var result = ProductsDataSource.Select(DataSourceSelectArguments.Empty) as DataView; Debug.Assert(result != null, nameof(result) + " != null"); string path = result[0]["img_url"].ToString(); // Get all png and jpg files in current dir only var images = Directory.GetFiles(Server.MapPath(path) ?? throw new InvalidOperationException(), "*", SearchOption.TopDirectoryOnly) .Where(file => file.EndsWith(".png") || file.EndsWith(".jpg") || file.EndsWith(".jpeg")); // Resolve physical paths to server-relative paths List <string> files = images.Select(img => path + "/" + Path.GetFileName(img)).ToList(); return(files[0]); }
protected void BtnSearch_Click(object sender, EventArgs e) { ProductsDataSource.Select(DataSourceSelectArguments.Empty); }