How to validate input with datagrid control?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • suresh

    How to validate input with datagrid control?

    How to validate input with datagrid control? i tried
    the following code from msdn...i have problem in adding
    handler to the columnchanging event..its not working for
    me? any bug in this code? is there any other way to
    validate input with datagrid control? waiting for good
    solution.thanks in advance.

    -suresh

    -----------------------------------------------------
    Private Sub Customers_Colum nChanging(ByVal sender As
    Object, _
    ByVal e As System.Data.Dat aColumnChangeEv entArgs)
    ' Only check for errors in the Product column
    If (e.Column.Colum nName.Equals("P roduct")) Then
    ' Do not allow "Automobile " as a product.
    If CType(e.Propose dValue, String) = "Automobile "
    Then
    Dim badValue As Object = e.ProposedValue
    e.ProposedValue = "Bad Data"
    e.Row.RowError = "The Product column contians an
    error"
    e.Row.SetColumn Error(e.Column, "Product cannot
    be " & _
    CType(badValue, String))
    End If
    End If
    End Sub
    ---------------------------------------------
    Connect the event handler to the event.
    Place the following code within either the form's Load
    event or its constructor.

    ' Visual Basic
    ' Assumes the grid is bound to a dataset called
    customersDataSe t1
    ' with a table called Customers.
    ' Put this code in the form's Load event or its
    constructor.
    AddHandler customersDataSe t1.Tables
    ("Customers").C olumnChanging, AddressOf
    Customers_Colum nChanging

    -----------------------------------------------------


Working...