here i m giving code in vb.net
1. First make property of that fields like
Public Property StudentPhoto() As Object
Get
Return _StudentPhoto
End Get
Set(ByVal value As Object)
If IsDBNull(value) = True Then
_StudentPhoto = value
_PhotoPath = ""
Else
If value.GetType.Name = "String" Then
_PhotoPath = System.Web.HttpContext.Current.ApplicationInstance.Server.MapPath(value.ToString)
Dim st As New System.IO.FileStream(_PhotoPath, System.IO.FileMode.Open, System.IO.FileAccess.Read)
Dim mbr As System.IO.BinaryReader = New IO.BinaryReader(st)
Dim buffer(st.Length) As Byte
mbr.Read(buffer, 0, CInt(st.Length))
_StudentPhoto = buffer
Else
_StudentPhoto = value
Dim arrPhoto() As Byte = CType(_StudentPhoto, Byte())
_StudentPhoto = arrPhoto
Dim stPhote As New IO.MemoryStream(arrPhoto)
_PhotoPath = "/PhotoUpload/" & _PhotoID & ".jpeg"
Try
Dim imgPhoto As Image = Image.FromStream(stPhote)
imgPhoto.Save(System.Web.HttpContext.Current.ApplicationInstance.Server.MapPath(_PhotoPath), Imaging.ImageFormat.Jpeg)
_PhotoPath = "~" & _PhotoPath
Catch ex As Exception
_StudentPhoto = DBNull.Value
_PhotoPath = ""
End Try
End If
End If
End Set
End Property
2. and on UI set valuetoobject means set value to object
like
Dim Recordid As Integer = objStudentConvo.GetStudentConvoRecordID(Session("UserMailID"))
If upimgphoto.ImageUrl = "~/PhotoUpload/New/Blank.jpg" Then
objStudentPhotocls.StudentPhoto = DBNull.Value
Else
objStudentPhotocls.StudentPhoto = upimgphoto.ImageUrl
End If
objStudentPhotocls.ConvoID = objStudentConvo.ConvoID
objStudentPhotocls.RecordID = Recordid
3. Update this object by sending this object to stored procedure