This is a migrated thread and some comments may be shown as answers.

Gridview NEWROW Insert

1 Answer 137 Views
GridView
This is a migrated thread and some comments may be shown as answers.
jorge
Top achievements
Rank 1
jorge asked on 31 Aug 2009, 09:22 PM
Hi, I am trying to insert a new row with the Winform RadGridView Control.

This is my Grid Code
Dim Cod As New GridViewDataColumn("ID""DOM_ID")  
            Dim Domicilio As New GridViewTextBoxColumn("DOMICILIO")  
            Dim Provincia As New GridViewComboBoxColumn("PROVINCIA")  
            Dim Localidad As New GridViewComboBoxColumn("LOCALIDAD")  
            Dim Cp As New GridViewTextBoxColumn("CP")  
 
 
            'COLUMNAS HEADER  
            Domicilio.HeaderText = "Domicilio" 
            Provincia.HeaderText = "Provincia" 
            Localidad.HeaderText = "Localidad" 
            Cp.HeaderText = "CP" 
 
            'COLUMNAS VALORES  
            Provincia.DisplayMember = "PRO_NOMBRE" 
            Provincia.DataField = "DOM_PRO_ID" 
            Provincia.ValueMember = "PRO_ID" 
            Provincia.DataSource = mgrEntidades.ObtenerProvincias  
 
            Localidad.DisplayMember = "LOC_NOMBRE" 
            Localidad.DataField = "DOM_LOC_ID" 
            Localidad.ValueMember = "LOC_ID" 
            Localidad.DisplayMember = "LOC_NOMBRE" 
            Localidad.DataSource = mgrEntidades.ObtenerLocalidades  
 
            Cp.DataField = "DOM_CP" 
            Domicilio.DataField = "DOM_DOMICILIO" 
 
            'AGREGAR COLUMNAS  
            gv_Domicilio.Columns.Add(Cod)  
            gv_Domicilio.Columns.Add(Domicilio)  
            gv_Domicilio.Columns.Add(Provincia)  
            gv_Domicilio.Columns.Add(Localidad)  
            gv_Domicilio.Columns.Add(Cp) 


This is my Update Code.

    Private Sub gv_Domicilio_CellEndEdit(ByVal sender As ObjectByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles gv_Domicilio.CellEndEdit  
        If Not e.RowIndex = -1 Then 
            Dim Dom As New Domicilio  
            With Dom  
                .id = CInt(TryCast(sender, RadGridView).Rows(e.RowIndex).Cells(0).Value)  
                .domicilio = TryCast(sender, RadGridView).Rows(e.RowIndex).Cells(1).Value  
                .provincia = New Provincia  
                .provincia.id = TryCast(sender, RadGridView).Rows(e.RowIndex).Cells(2).Value  
                .localidad = New Localidad  
                .localidad.id = TryCast(sender, RadGridView).Rows(e.RowIndex).Cells(3).Value  
                .cp = TryCast(sender, RadGridView).Rows(e.RowIndex).Cells(4).Value  
            End With 
            mgrCliente.GuardarDomicilio(CInt(TryCast(sender, RadGridView).Rows(e.RowIndex).Cells(0).Value), Dom)  
        End If 
    End Sub 

I want to validate "ALL" cells values before insert the new Record but i dont know how.

Regards!

Geoorge.

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 01 Sep 2009, 01:13 PM
Hi jorge,

You can use RowValidating and CellValidating events to validate cell values. This behavior is demonstrated in "GridView -> Validation" example in our demo application. It will be better to use RowValidated event for the update code. If you have any further questions, don't hesitate to write back.

Best wishes,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
jorge
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or