Hola amigos!!!
He encontrado una falla al crear un grid editable en el webmatrix usando
el asistente que muestra un ejemplo con la base pubs y de alli uno tiene que
modificar las sentencias SQL.
Escribo esto para que no les pase a ustedes porque he sufrido mucho por ese
error.
Lo que pasa es que al hacer clic en ingresar nuevo item o (add new item) si
tienes tu tabla vacia se genera error y no te da opción a modificar nada.
Este es el codigo y con mayuscula el error!!!!
Sub AddNew_Click(Sender As Object, E As EventArgs)
' add a new row to the end of the data, and set editing mode
'on'
CheckIsEditing("")
If Not isEditing = True Then
' set the flag so we know to do an insert at Update time
AddingNew = True
' add new row to the end of the dataset after binding
' first get the data
Dim myConnection As New SqlConnection(ConnectionString)
Dim myCommand As New SqlDataAdapter(SelectCommand,
myConnection)
Dim ds As New DataSet()
myCommand.Fill(ds)
' add a new blank row to the end of the data
Dim rowValues As Object() {p.selecteditem.value,0,0,0,0,0,0,0, "-", 2}
ds.Tables(0).Rows.Add(rowValues)
' figure out the EditItemIndex, last record on last page
Dim recordCount As Integer = ds.Tables(0).Rows.Count
If recordCount > 1 Then ' AQUI ESTA EL ERROR!!!! debe decir
=1
recordCount -= 1
DataGrid1.CurrentPageIndex = recordCount \
DataGrid1.PageSize
DataGrid1.EditItemIndex = recordCount Mod
DataGrid1.PageSize
End If
' databind
DataGrid1.DataSource = ds
DataGrid1.DataBind()
End If
Espero para los poco experimentados como yo, nunca mas tengan este
problema!!!
Saludos!!!
Leer las respuestas