for (int i = 0; i < ds.Tables.Rows.Count; i++)
int itemid = Convert.ToInt32(ds.Tables.Rows[i]);
img.ImageUrl = "~/Handler1.ashx?id=" + itemid;
The reason is that you are looping through all the rows in a the dataset, and then setting the imageUrl to the last one every time. What you really need to ask yourself is Why are you using a loop if you only have 1 image on the row?