Visual Basic.NET - gridview

 
Vista:

gridview

Publicado por marco (3 intervenciones) el 15/09/2011 23:13:01
hola necesito una ayudita

estoi tratando de validar dos columnas en un gridview pero cuando estoy tratando de entrar a un for each no entra manda el error alguien me puede ayudar plis
les pongo el script

Protected Sub btn_validar_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_validar.Click

Dim s As StreamReader
Dim c As Control
Dim y As Control
Dim contador As Integer
Dim archivos(10) As String
Dim cant_archivos As Integer = 0
For Each r As GridViewRow In gv_archivos.Rows
For Each c In r.Cells(4).Controls
contador += 1
If (c.GetType.ToString().ToLower.Contains("fileupload")) Then
Dim fu As FileUpload = c
s = New StreamReader(fu.PostedFile.InputStream)
If (fu.PostedFile.ContentLength > 0) Then
MsgBox(fu.PostedFile.FileName)
MsgBox("2 FOR")
MsgBox(r.Cells(2).Text)

'NO ENTRA EN ESTE FOR EACH

Dim acum As Integer
For Each y In r.Cells(2).Controls

MsgBox(r.Cells(2).Text)
acum += 1
MsgBox("2")
' y = r.Cells(2).Controls

If y.GetType.ToString().ToLower.Contains("label") Then

Dim lbl As Label = y
MsgBox("3")
If (fu.PostedFile.FileName = r.Cells(2).Text) Then
r.Cells(3).Text = "Archivo Encontrado"
lbl.ForeColor = Drawing.Color.Green
MsgBox("archivo encontrado")
cant_archivos += 1
Else
r.Cells(3).Text = "Archivo No Encontrado"
lbl.ForeColor = Drawing.Color.Red
MsgBox("archivo no encontrado")
End If
End If




archivos(contador) = Mid(fu.PostedFile.FileName, 48, 10)

MsgBox(archivos(contador))
Next
End If

End If
Next
Next
'If cant_archivos = gv_archivos.Rows.Count Then
If cant_archivos > 0 Then
MsgBox("111")
Dim msg() As Mensajes = {New Mensajes()}
For Each r As GridViewRow In gv_archivos.Rows
msg = sql_cnx.CreateInsert_CreateInserts(r.Cells(2).Text, _
Session("cdg_cpr").ToString(), _
s, _
sql_cnx.CreateInsert_GetTableDefinition(r.Cells(2).Text), _
msg)
MsgBox(msg)
If msg IsNot Nothing Then
If msg.Length > 0 Then
If msg(msg.Length - 1).Es_Error Then
If msg IsNot Nothing Then
Session.Add("msg", msg)
Response.Redirect("~\Pages\Mensajes.aspx")
End If
Exit For
End If
End If
End If
Next
Session.Add("msg", msg)
Response.Redirect("~\Pages\Mensajes.aspx")
End If


End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

gridview

Publicado por Damian (824 intervenciones) el 16/09/2011 14:18:36
Y ese r.Cells(2).Controls posee algo dentro, no estará vació? porque no pones un punto de interrupción antes de ese for y así vas viendo los valores de las variables y demás.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

gridview

Publicado por marco (3 intervenciones) el 16/09/2011 16:20:58
Gracias Damian
ya hice el punto de interrupción y en el MsgBox(r.Cells(2).Text) antes del for me trae los datos pero no entra en el for debe haber algo que esta impidiendo entre en el bucle
cualquier otra sugerencia me la haces saber

gracias y saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar