Hi guys

I'm playing with XML, DataGridView control, DataSet and DataTable.
Here's my code:
vb.net Code:
  1. Imports System.Xml
  2. Imports System.Data
  3.  
  4. Public Class Form1
  5.     Dim dt As DataTable
  6.     Dim ds As New DataSet
  7.  
  8.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  9.  
  10.         dt = New DataTable("product")
  11.         dt.Columns.Add(New DataColumn("Product_ID", Type.GetType("System.Int32")))
  12.         dt.Columns.Add(New DataColumn("Product_Name", Type.GetType("System.String")))
  13.         dt.Columns.Add(New DataColumn("product_Price", Type.GetType("System.Int32")))
  14.         fillRows(1, "product1", 1111)
  15.         fillRows(2, "product2", 2222)
  16.         fillRows(3, "product3", 3333)
  17.         fillRows(4, "product4", 4444)
  18.         ds.Tables.Add(dt)
  19.  
  20.         ds.DataSetName = "company"
  21.  
  22.         DataGridView1.DataSource = dt
  23.        
  24.     End Sub
  25.  
  26.     '~~~ To fill sample rows
  27.     Private Sub fillRows(ByVal pID As Integer, ByVal pName As String, ByVal pPrice As Integer)
  28.         Dim dr As DataRow
  29.         dr = dt.NewRow()
  30.         dr("Product_ID") = pID
  31.         dr("Product_Name") = pName
  32.         dr("product_Price") = pPrice
  33.         dt.Rows.Add(dr)
  34.     End Sub
  35.  
  36.     '~~~ Save as XML    
  37.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  38.         ds.WriteXml("c:\Product.xml")
  39.         MsgBox("Done")
  40.     End Sub
  41.  
  42. End Class
My question is, the user can edit/add records via DataGridView control. So, when the user enters a string value where it is expected to give an integer value(first column and third column), it would give a big error message. Instead of showing that, I would like to apply custom validations.

How would I do it ?

Thanks