the SS of my current App
I set all the codes to retrieve the information from the SQL table , now i only need to convert the retrieved image URL to Image in the DataGridView
here is the codes am using now :
namespace LamasoDemo
{
public partial class FormOrders : Form
{
public FormOrders()
{
InitializeComponent();
FillGridView();
}
void FillGridView()
{
List<Products> productsList = new List<Products>();
Products products = new Products();
productsList = products.GetProducts();
dataGridViewProducts.DataSource = productsList;
}
and on the class here is the codes :
public class Products
{
public string? Image { get; set; }
string connectionString = "Data Source=AHMEDBABAJAN;Initial Catalog=Lamaso1;Integrated Security=True;Trust Server Certificate=true";
public List<Products> GetProducts()
{
List<Products> ProductsList = new List<Products>();
SqlConnection con = new SqlConnection(connectionString);
string selectSQL = "select Image Status From GetProductsData";
con.Open();
SqlCommand cmd = new SqlCommand(selectSQL, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr != null)
{
while (dr.Read())
{
Products Products = new Products();
Products.Image = dr["Image"].ToString();
ProductsList.Add(Products);
}
}
return ProductsList;
}
Anyone have any idea on how to show the image ? from URL
Products
(should be single) class that needs to retrive the Image when you pass the URI to it -- You should probably avoid naming a PropertyImage
, when it actually stores theImageUri
. When you do that, it's also easier to retrieve a thumbnail of the real image, then show the original (larger) image when / if required