 <p>Sorry if my vb is wrong as im a c# guy!! but I hope this should give you a guidance. I do something similar in c#. Good luck</p> <pre><code>Protected Sub dvPictureInsert_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles dvPictureInsert.ItemInserting Dim cancelInsert As Boolean = False Dim imageUpload As FileUpload = CType(dvPictureInsert.FindControl("imageUpload"), FileUpload) If Not imageUpload.HasFile Then cancelInsert = True Else If Not imageUpload.FileName.ToUpper().EndsWith(".JPG") Then cancelInsert = True 'Invalid image file! Else Dim image As System.Drawing.Image = System.Drawing.Image.FromStream(imageUpload.PostedFile.InputStream) If image.Width &gt; 600 Or image.Height &gt; 700 Then cancelInsert = True End If End If End If //etc </code></pre>