Daniel Alejandro
Top achievements
Rank 1
Daniel Alejandro
asked on 16 Jul 2010, 06:47 PM
I need my radgrid accept N number of values showing the fields to fill,I add that when you close a form where you insert the fields and just clean it.
3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 19 Jul 2010, 07:45 AM
Hello Daniel,
Adding the following code in ItemInserted event will help you to remain the insertform opened, even after clicking "Insert" button.
C#:
-Shinu.
Adding the following code in ItemInserted event will help you to remain the insertform opened, even after clicking "Insert" button.
C#:
protected
void
RadGrid1_ItemInserted(
object
source, GridInsertedEventArgs e)
{
e.KeepInInsertMode =
true
;
}
-Shinu.
0
Daniel Alejandro
Top achievements
Rank 1
answered on 20 Jul 2010, 05:11 PM
Thanks Shinu,
But i tried that but I have few events with the buttons in the templates that are update, cancel and insert, which have methods with GridCommandEventArgs and still not find a way to trim use the code you recommended I leave my code also want a multiple insertion of records
But i tried that but I have few events with the buttons in the templates that are update, cancel and insert, which have methods with GridCommandEventArgs and still not find a way to trim use the code you recommended I leave my code also want a multiple insertion of records
Protected Sub RadGridPasajero_UpdateCommand(ByVal source As Object, ByVal e As GridCommandEventArgs)
Try
Dim oServicio As New Objects.RvaServicioObj
If Not IsNothing(Session("Servicio")) Then
oServicio = Session("Servicio")
End If
Dim iRegistroInsertado As Integer = 0
'Get the GridEditableItem of the RadGrid
Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
'Get the primary key value using the DataKeyValue.
Dim index As Integer = (TryCast(editedItem.FindControl("txtPgrIndex"), TextBox)).Text
Dim id As Integer = (TryCast(editedItem.FindControl("txtPgrPasajeroID"), TextBox)).Text
Dim nombre As String = (TryCast(editedItem.FindControl("txtPgrNombre"), TextBox)).Text.ToUpper
Dim apellido As String = (TryCast(editedItem.FindControl("txtPgrApellido"), TextBox)).Text.ToUpper
Dim edad As String = (TryCast(editedItem.FindControl("ddPgrEdad"), DropDownList)).SelectedValue
Dim edad_Text As String = (TryCast(editedItem.FindControl("ddPgrEdad"), DropDownList)).SelectedItem.Text
Dim edad_Numero As Integer
If ((TryCast(editedItem.FindControl("txtEdadNumero"), TextBox)).Text.Trim = "") Then
edad_Numero = 0
Else
edad_Numero = (TryCast(editedItem.FindControl("txtEdadNumero"), TextBox)).Text
End If
Dim titular As Boolean = (TryCast(editedItem.FindControl("chkTitular"), CheckBox)).Checked
Dim oPasajeroObj As New Objects.SvrPasajeroObj
With oPasajeroObj
.Index = index
.PasajeroID = id
.Nombre = QuitaApostrofe(nombre)
.Apellidos = QuitaApostrofe(apellido)
.Edad = edad
.Edad_Text = edad_Text
.Edad_Numero = FixIntNull(edad_Numero)
.Titular = titular
.Borrado = False
End With
For Each oPasajero As Objects.SvrPasajeroObj In oServicio.SvrPasajero
If (oPasajero.Nombre = oPasajeroObj.Nombre And oPasajero.Apellidos = oPasajeroObj.Apellidos And oPasajero.Edad_Text = oPasajeroObj.Edad_Text And oPasajero.Borrado = False And oPasajeroObj.Index <> oPasajero.Index) Then
iRegistroInsertado = 1
Exit For
End If
If (oPasajeroObj.Titular = True And oPasajero.Titular = True And oPasajeroObj.Index <> oPasajero.Index And oPasajero.Borrado = False) Then
oPasajeroObj.Titular = False
iRegistroInsertado = 2
End If
Next
If iRegistroInsertado = 0 Or iRegistroInsertado = 2 Then
oServicio.SvrPasajero.Item(oPasajeroObj.Index) = oPasajeroObj
Session("Servicio") = oServicio
If (oPasajeroObj.Titular = True) Then
Me.txtGenNombre.Text = oPasajeroObj.Nombre & " " & oPasajeroObj.Apellidos
End If
If (Me.txtGenNombre.Text = oPasajeroObj.Nombre & " " & oPasajeroObj.Apellidos And oPasajeroObj.Titular = False) Then
Me.txtGenNombre.Text = String.Empty
End If
If iRegistroInsertado = 2 Then
Me.ShowMessageBox("Ya existe un pasajero titular, el pasajero se actualizo pero como acompañante")
Else
'Me.ShowMessageBox("Pasajero Actualizado")
End If
Else
If iRegistroInsertado = 1 Then
Me.ShowMessageBox("Ya el pasajero NO se actualizo razon: existe un registro con esa clave o descripcion")
End If
End If
' e.KeepInInsertMode = True
Catch ex As Exception
Me.ShowMessageBox("Error al Actualizar pasajero: " & ex.ToString())
e.Cancel = True
End Try
End Sub
Protected Sub RadGridPasajero_InsertCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGridPasajero.InsertCommand
Try
If (PasajeroInsert = 0) Then
Dim oServicio As Objects.RvaServicioObj = New Objects.RvaServicioObj
If Not IsNothing(Session("Servicio")) Then
oServicio = Session("Servicio")
End If
Dim iRegistroInsertado As Integer = 0
'Get the GridEditFormInsertItem of the RadGrid
Dim insertedItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem)
'Access the textbox from the insert form template and store the values in string variables.
Dim nombre As String = (TryCast(insertedItem.FindControl("txtPgrNombre"), TextBox)).Text.ToUpper
Dim apellido As String = (TryCast(insertedItem.FindControl("txtPgrApellido"), TextBox)).Text.ToUpper
Dim edad As String = (TryCast(insertedItem.FindControl("ddPgrEdad"), DropDownList)).SelectedValue
Dim edad_Text As String = (TryCast(insertedItem.FindControl("ddPgrEdad"), DropDownList)).SelectedItem.Text
Dim edad_Numero As Integer
If ((TryCast(insertedItem.FindControl("txtEdadNumero"), TextBox)).Text.Trim = "") Then
edad_Numero = 0
Else
edad_Numero = (TryCast(insertedItem.FindControl("txtEdadNumero"), TextBox)).Text
End If
Dim titular As Boolean = (TryCast(insertedItem.FindControl("chkTitular"), CheckBox)).Checked
Dim oPasajeroObj As New Objects.SvrPasajeroObj
With oPasajeroObj
.Nombre = QuitaApostrofe(nombre)
.Apellidos = QuitaApostrofe(apellido)
.Edad = edad
.Edad_Text = edad_Text
.Edad_Numero = FixIntNull(edad_Numero)
.Titular = titular
.Borrado = False
End With
If oServicio.SvrPasajero.Count = 0 Then
iRegistroInsertado = 0
Else
For Each pasajero As Objects.SvrPasajeroObj In oServicio.SvrPasajero
If pasajero.Titular = True And oPasajeroObj.Titular = True And Not pasajero.Borrado = True Then
iRegistroInsertado = 1
oPasajeroObj.Titular = False
End If
Next
End If
oServicio.SvrPasajero.Add(oPasajeroObj)
PasajeroInsert = 1
'Dim index As Integer = 0
'For Each pasajero As Objects.SvrPasajeroObj In oServicio.SvrPasajero
' pasajero.Index = index
'index = index + 1
'Next
Session("Servicio") = oServicio
If (oPasajeroObj.Titular = True) Then
Me.txtGenNombre.Text = oPasajeroObj.Nombre & " " & oPasajeroObj.Apellidos
End If
If (Me.txtGenNombre.Text = oPasajeroObj.Nombre & " " & oPasajeroObj.Apellidos And oPasajeroObj.Titular = False) Then
Me.txtGenNombre.Text = String.Empty
End If
If iRegistroInsertado = 1 Then
Me.ShowMessageBox("Ya existe un pasajero titular, el pasajero se agrego pero como acompañante")
Else
'Me.ShowMessageBox("Pasajero agregado")
End If
Else
PasajeroInsert = 0
End If
Catch ex As Exception
Me.ShowMessageBox("Error al Insertar Pasajero: " & ex.ToString())
e.Canceled = True
End Try
'e.KeepInInsertMode = True
End Sub
Protected Sub RadGridPasajero_DeleteCommand(ByVal source As Object, ByVal e As GridCommandEventArgs)
Try
Dim oServicio As New Objects.RvaServicioObj
oServicio = New Objects.RvaServicioObj
If Not IsNothing(Session("Servicio")) Then
oServicio = Session("Servicio")
End If
'Get the GridDataItem of the RadGrid
Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
'Get the primary key value using the DataKeyValue.
Dim RegistroID As String = item.OwnerTableView.DataKeyValues(item.ItemIndex)("INTERNAL").ToString()
oServicio.SvrPasajero.Item(RegistroID).Borrado = True
Session("Servicio") = oServicio
If oServicio.SvrPasajero.Item(RegistroID).Titular = True Then
Me.txtGenNombre.Text = String.Empty
End If
Me.ShowMessageBox("Se elimino el pasajero " & oServicio.SvrPasajero.Item(RegistroID).Nombre & " " & oServicio.SvrPasajero.Item(RegistroID).Apellidos)
Catch ex As Exception
Customs.Functions.ErrorGrid(RadGridPasajero, ex.ToString, 3)
e.Canceled = True
End Try
End Sub
Protected Sub GetPasajero(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs) Handles RadGridPasajero.NeedDataSource
Try
Dim oServicio As Objects.RvaServicioObj
oServicio = New Objects.RvaServicioObj
Dim dt As DataTable = New DataTable
dt.Columns.Add("INTERNAL", Type.GetType("System.Int32"))
dt.Columns.Add("PASAJEROID", Type.GetType("System.Int32"))
dt.Columns.Add("NOMBRE", Type.GetType("System.String"))
dt.Columns.Add("APELLIDO", Type.GetType("System.String"))
dt.Columns.Add("EDAD", Type.GetType("System.String"))
dt.Columns.Add("EDAD_TEXT", Type.GetType("System.String"))
dt.Columns.Add("EDAD_NUMERO", Type.GetType("System.Int32"))
dt.Columns.Add("TITULAR", Type.GetType("System.Boolean"))
If Not IsNothing(Session("Servicio")) Then
oServicio = Session("Servicio")
Dim index As Integer = 0
For Each pasajero As Objects.SvrPasajeroObj In oServicio.SvrPasajero
With (pasajero)
pasajero.Index = index
index = index + 1
If Not .Borrado = True Then
Dim Titulo As String = ""
If (.Edad = 0) Then
Titulo = ""
Else
Titulo = .Edad_Text
End If
dt.Rows.Add(.Index, .PasajeroID, QuitaApostrofe(.Nombre), QuitaApostrofe(.Apellidos), .Edad, Titulo, .Edad_Numero, .Titular)
End If
End With
Next
Session("Servicio") = oServicio
End If
Me.RadGridPasajero.DataSource = dt
Catch ex As Exception
Me.ShowMessageBox(ex.Message)
End Try
End Sub
0
Hi Daniel,
In order to achieve your goal, try setting the grid MasterTableView.IsItemInserted property to true at the end of the insertCommand event handler and see if that works for you.
Kind regards,
Iana
the Telerik team
In order to achieve your goal, try setting the grid MasterTableView.IsItemInserted property to true at the end of the insertCommand event handler and see if that works for you.
Kind regards,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items