SoloCodigo
CLR: .Net / Mono / Boo / Otros CLR => ASP .NET => Mensaje iniciado por: alexisgondola en Martes 12 de Junio de 2012, 20:43
-
buenos dias que tal, estaba intentando traduccir esto de visual basic a c # pero en c char no me funciona
Dim Trim1, Trim2, Trim3, Trim4 As TextBox
Trim1 = gvrow.Cells(5).Controls(1)
Trim2 = gvrow.Cells(6).Controls(1)
Trim3 = gvrow.Cells(7).Controls(1)
Trim4 = gvrow.Cells(8).Controls(1)
estoy usando aspx visual studio 2010
lo traduje asi y me manda error , intente de dos formas
foreach (GridViewRow gvrow in gvDatos.Rows)
{
TextBox Trim1, Trim2;
Trim1 = gvrow.Cells[2].Controls(1); // manda error
Trim2 = gvrow.Cells(3).Controls[1]; // manda error
//if( ! IsNumeriec(Trim1.Text.Trim()) ) Trim1.Text = 0;
//if( ! IsNumeric(Trim2.Text.Trim()) ) Trim2.Text = 0;
}
-
Dim Trim1, Trim2, Trim3, Trim4 As TextBox
Trim1 = gvrow.Cells(5).Controls(1)
Trim2 = gvrow.Cells(6).Controls(1)
Trim3 = gvrow.Cells(7).Controls(1)
Trim4 = gvrow.Cells(8).Controls(1)
es igual a
TextBox Trim1 = (TextBox)gvrow.Cells[5].Controls[1]; //--> Checa si existe control en la posion 1 o en l a 0
TextBox Trim2 = (TextBox)gvrow.Cells[6].Controls[1]; //--> Checa si existe control en la posion 1 o en l a 0
TextBox Trim3 =(TextBox)gvrow.Cells[7].Controls[1]; //--> Checa si existe control en la posion 1 o en l a 0
TextBox Trim4 = (TextBox)gvrow.Cells[8].Controls[1]; //--> Checa si existe control en la posion 1 o en l a 0
foreach (GridViewRow gvrow in gvDatos.Rows)
{
TextBox Trim1 = (TextBox)gvrow.Cells[2].Controls[1];
// o tambien puede hacer esto
TextBox Trim1 = (TextBox)gvrow.findcontrol(idTextboxTemplate);
//luego tienes que compararlo que si es diferente que null para no generar una exception
if(Trim1 != null)
{
//hacer las operaciones que quieres con el
}
}