FALLA EN WEBMATRIX

22/09/2004 - 19:18 por CRISTHIAN MASSA MEDINA | Informe spam
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

#1 Jorge Serrano [MVP VB]
22/09/2004 - 21:50 | Informe spam
Muchas gracias por avisar. :-)

Se agradece.

Un saludo,

Jorge Serrano Pérez
Microsoft MVP VB.NET
PortalVB.com
http://www.portalvb.com/
Weblog de Jorge Serrano
http://weblogs.golemproject.com/jorge/
No te olvides de:
http://www.microsoft.com/spanish/ms...des/vbnet/

Frase: "Si le das pescado a un hombre hambriento, le nutres durante una
jornada. Si le enseñas a pescar, le nutrirás toda su vida." Lao-Tsé - 600 AC
[aprox]


"CRISTHIAN MASSA MEDINA" <news.microsoft.com11> escribió en el mensaje
news:
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!!!



Preguntas similares