First thing I do is create a Datatable and then bind it to a GridView
Here is my code
DataTable dt = new DataTable();
DataColumn imgC = dt.Columns.Add("img", typeof(string));
DataRow row1 = dt.NewRow();
row1["img"] = "~images/foo.png";
GridView gv = new GridView();
gv.DataSource = dt;
gv.DataBind();
cust_services.Controls.Add(gv);
I'm not sure where to go from here, as it just displays text, I have tried creating an Image and just writing
row1["img"] = img;
You can make use of
<asp:ImageField/>
within the theGridview
to achieve this. So your markup will look likeIn your C# code you can use
List
to add the images. So something as simple asThis will only add one image to the grid. If you want to add all the images to the grid that are in a particular directory then just use a
foreach
loop.