Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_espanol thread: problemas con FindByValue


Message #1 by "Daniel Chavez" <chavezd@r...> on Wed, 24 Apr 2002 15:40:39 -0500
This is a multi-part message in MIME format.

------=_NextPart_000_000F_01C1EBBD.C7F0D500
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hazle un type casting a String al campo de la base de datos y luego
ponle .TRIM()

C#
((String)Nombrecampo.value).TRIM();

VB
CStr(nombrecampo.Value).TRIM()

y con eso removiste todos los espacios en blanco tanto de la izquierda
como de la derecha no lo que estan en medio de los caracteres

Jose Ramon Suero Paulino
.NET Student
-----Original Message-----
From: Daniel Chavez [mailto:chavezd@r...]
Sent: Mi=E9rcoles, 24 de Abril de 2002 05:38 p.m.
To: ASP.Net en Espa=F1ol
Subject: [aspx_espanol] RE: problemas con FindByValue

Valeria
sabes cual era el error? pues en la tabla me pusieron los datos del tipo
char en lugar de varchar, por eso no encontraba el value, tuve que hacer
un bucle para llenar los espacios en blanco que faltaban!!!!

gracias por ayudar Valeria!!! sos como martha la numero uno!!

----- Original Message -----
From: Valeria <mailto:valerial@f...>  Lasagna
To: ASP.Net <mailto:aspx_espanol@p...>  en Espa=F1ol
Sent: Wednesday, April 24, 2002 4:14 PM
Subject: [aspx_espanol] RE: problemas con FindByValue

Hola Daniel, estamos iguales.. Postule un problema similar..
Fijate si el valor que le pasas para que busque dentro del combo existe.
Por el error que te esta dando, no esta encontrando el dato en el combo.
Se esta tratando de poscionar en un
item que no encuentra.

Igualmente proba lo siguiente:

Dim list As ListItem
list =3D cmbCarreras.Items.FindByValue(Valor)
cmbCarreras.SelectedIndex=3D list.Value()

Lo que podes hacer es fijarte el valor de ?list.value desde el Command
Windows debaguendo la app.
y ver si encuentra el valor. Si no lo encuentra, hay que revisar la
carga del combo.. Es dinamica?

Espero que te sirva, saludos. Valeria.

----- Original Message -----
From: Daniel <mailto:chavezd@r...>  Chavez
To: ASP.Net <mailto:aspx_espanol@p...>  en Espa=F1ol
Sent: Wednesday, April 24, 2002 5:40 PM
Subject: [aspx_espanol] problemas con FindByValue

Hola muchachos tengo un problemita con un dropdownlist, tengo el sgte
codigo:

public void Page_Load(object sender, System.EventArgs e)
{
Llenar_ddl_UsuarioReporte();
Llenar_Datos();
}

public void LlenarDatos()
{
SqlConnection conn =3D new
SqlConnection("..............................");
   string sql =3D "................................") ;
   SqlCommand cmd =3D new SqlCommand(sql,conn);
   cmd.Connection.Open();
   SqlDataReader dr =3D
cmd.ExecuteReader(CommandBehavior.CloseConnection);   
   dr.Read();
   txtb_IncidenteNumero.Text =3D dr.GetInt32(0).ToString();
   txtb_CompaniaSocio.Text =3D dr.GetString(1);
   txtb_Secuencia.Text =3D dr.GetInt32(2).ToString();
   txa_c_Comentario.Value =3D dr.GetString(3);
   txtb_UsuarioReporte.Text =3D dr.GetString(4);

ddl_UsuarioReporte.Items.FindByValue(txtb_UsuarioReporte.Text).Selected
=3D true;
   txtb_UltimoUsuario.Text =3D dr.GetString(5);
   txtb_UltimaFechaModif.Text =3D dr.GetDateTime(6).ToString();
conn.Close();
}


public void Llenar_ddl_UsuarioReporte()
  {  
   Incidentes.localhost1.dropdownlist dropDownWeb =3D new
Incidentes.localhost1.dropdownlist();
   DataSet dsUsuarioReporte =3D
dropDownWeb.llenandoDropDown("RS_Usuario","Usuario","Descripcion");
   ddl_UsuarioReporte.DataSource =3D dsUsuarioReporte;
   ddl_UsuarioReporte.DataTextField =3D "Descripcion";
   ddl_UsuarioReporte.DataValueField =3D "Usuario";
   ddl_UsuarioReporte.DataBind();
  }

Espero su ayuda!!!! 


  _____ 

 Server Error in '/RoyalWeb/Incidentes' Application.

  _____ 


Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.

Source Error:

Line 121:                      txa_c_Comentario.Value =3D 
dr.GetString(3);
Line 122:                      txtb_UsuarioReporte.Text =3D
dr.GetString(4);
Line 123:
ddl_UsuarioReporte.Items.FindByValue(txtb_UsuarioReporte.Text).Selected
=3D true;
Line 124:                      txtb_UltimoUsuario.Text =3D
dr.GetString(5);
Line 125:                      txtb_UltimaFechaModif.Text =3D
dr.GetDateTime(6).ToString();

Source File:
c:\inetpub\wwwroot\royalweb\incidentes\p_rs_incidente_avance_edit.aspx.c
s    Line: 123


Atte.

Daniel Chavez B




---
Usted est=E1 suscrito a aspx_espanol como:
valerial@f...
Para darse de baja, env=EDe un mensaje en blanco a
%%email.unsub%%
---
Usted est=E1 suscrito a aspx_espanol como:
chavezd@r...
Para darse de baja, env=EDe un mensaje en blanco a
%%email.unsub%%
---
Usted est=E1 suscrito a aspx_espanol como:
paulino.suero@c...
Para darse de baja, env=EDe un mensaje en blanco a
%%email.unsub%%



  Return to Index