in cell content click i wrote code like this:
Expand|Select|Wrap|Line Numbers
- If e.ColumnIndex = 4 Then
- Dim OFDLogo As New OpenFileDialog()
- OFDLogo.Filter = "JPEG(*.jpg)|*.jpg|BMP(*.bmp)|*.bmp"
- If OFDLogo.ShowDialog() = DialogResult.OK Then
- gv.Rows(e.RowIndex).Cells(4).Value = Image.FromFile(OFDLogo.FileName)
- End If
- End If
Expand|Select|Wrap|Line Numbers
- Dim cmpny As String = "Delete from CompanyMaster_tbl"
- Exetransaction(cmpny)
- For i As Integer = 0 To gv.RowCount - 2
- sqlInsertT2 = "Insert Into DepartmentMaster_tbl(dtname,dtphone,dtEmail,Cid) Values ('" + myTI.ToTitleCase(gv.Rows(i).Cells(1).Value) + "','" + gv.Rows(i).Cells(2).Value + "','" + gv.Rows(i).Cells(3).Value + "'," & Ccid & ");"
- Exetransaction(sqlInsertT2)
- Dim departmnt As String = gv.Rows(i).Cells(1).Value
- Dim departid As Integer = RecordID("dtId", "DepartmentMaster_tbl", "dtName", departmnt)
- Dim sql As String
- '----------------------------------
- Dim image As Image = TryCast(gv.Rows(i).Cells(4).Value, Image)
- If image IsNot Nothing Then
- Dim ms As New MemoryStream()
- image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif)
- Dim imagedata As Byte() = ms.ToArray()
- sql = "update DepartmentMaster_tbl set empimage=@photo where dtId='" & departid & "'"
- Dim cmd As New SqlCommand(sql, con.connect)
- cmd.Parameters.Add("@photo", SqlDbType.Image)
- cmd.Parameters("@photo").Value = imagedata
- cmd.ExecuteNonQuery()
- con.disconnect()
- End If
- Next
In cell content click I am taking row_index