Click here to Skip to main content
15,921,989 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
View
HTML
<table>   
    @{
        int j = 0;
        for (int i = 0; i < Model.Count(); i+=4)
        {
            j = i;
            <tr>
                @* I have done this for show 4 images in  a Row *@
                @while (j < i+4 && j < Model.Count())
             {
                    <td>
                        <img src="/Images/@ViewBag.Image" width="100" height="100" />
                    </td>
                    j++;
             }
            </tr>
        }
    }
</table>

Controller
C#
string query1 = "select ImageName from FileUploads Where UserId='"+User.UserId+"'";
                
SqlCommand cmd = new SqlCommand(query1, con);
cmd.CommandType = CommandType.Text;
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
  string name = dr["ImageName"].ToString();
  // string city = dr["City"].ToString();
  //Response.Write("Name: " + name);
  foreach (var img in name)
  {
    ViewBag.Image = name;

    //s Response.Write(img);
  }
}
con.Close();
the above code return only single Image 3 time the those user, i want to list of all image which is uploaded by the current user
Posted
Updated 24-Dec-14 20:21pm
v3
Comments
Member 11242168 25-Dec-14 2:43am    
@KornfeldEliyahuPeter ur updated code also not working sir...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900