Ver Mensaje Individual
  #1 (permalink)  
Antiguo 08/05/2012, 18:40
kire94
 
Fecha de Ingreso: enero-2006
Mensajes: 169
Antigüedad: 19 años, 1 mes
Puntos: 0
Pregunta No se puede convertir implícitamente el tipo 'int' en 'string'

Saludos cordiales al foro.

El panorama es el sigueinte:

1. Se llena el formulario "FORM_CARROS" y se guarda en la TABLA "Carros" con ID unico.

2. Se entra al aplicativo y el cliente desea modificar uno de los registros que grabo, ya que tiene errrores.

3.Para esto el formulario "FORM_CARROS" lo lleno con la informacion que ya existe en la TABLA CARROS, mediante un Stored Procedure.

4.Creo una clase llama "CARROS" la cual me trae la informacion del SP.

5.LLamo a la clase en mi codigo apx.cs y asigno los valores a los input_text y los Dropdownlist.

El error es el siguiente:

Cita:
No se puede convertir implícitamente el tipo 'int' en 'string'
Mi codigo:

Código:
//LA CLASE CARROS (carros.cs).
public class CARROS
    {
        private int idCarroPre;
        private int idTipo;
        private string representante;
        private string anyo_edicion;
        private string titulo;
        private string observaciones;
        
        /// <summary>
        /// Id del Carro
        /// </summary>
        public int IdCarroPre
        {
            get { return (this.idCarroPre); }
            set { idCarroPre = value; }
        }
        /// <summary>
        /// Id Tipo de Carro
        /// </summary>
        public int IdTipo
        {
            get { return (this.idTipo); }
            set { idTipo = value; }
        }
        /// <summary>
        /// Representante
        /// </summary>
        public string Representante
        {
            get { return (this.representante); }
            set { representante = value; }
        }
        
        /// <summary>
        /// Año de Edicion
        /// </summary>
        public string Anyo_edicion
        {
            get { return (this.anyo_edicion); }
            set { anyo_edicion = value; }
        }
        /// <summary>
        /// Titulo
        /// </summary>
        public string Titulo
        {
            get { return (this.titulo); }
            set { titulo = value; }
        }
        /// <summary>
        /// Observaciones
        /// </summary>
        public string Observaciones
        {
            get { return (this.observaciones); }
            set { observaciones = value; }
        }
       
        public static CARROS Init(int idLibroPre, int idRepre,string representante, string anyo_edicion, string titulo, string observaciones)
        {
            CARROS Micarro = new CARROS();
            Micarro.IdCarroPre = idCarroPre;
            Micarro.IdTipo = idTipo;
            Micarro.Representante = representante;
            Micarro.Anyo_edicion = anyo_edicion;
            Micarro.Titulo = titulo;
            Micarro.Observaciones = observaciones;

            return Micarro ;
        }


        public CARROS LeeCarro(int idCarro)
        {

            SqlParameter[] parameters = new SqlParameter[1];
            SqlDataReader reader = null;
            CARROS Micarro = null;


            try
            {
                parameters[0] = new SqlParameter("idCarro", SqlDbType.Int);
                parameters[0].Value = idCarro;

                reader = SqlHelper.ExecuteReader(Definitions.cadenaConexion, CommandType.StoredProcedure, "SpLeeCarroPre", parameters);
                if (reader.Read())
                {
                  

                    Micarro = CARROS.Init(Convert.ToInt32(reader["idCarroPre"]), Convert.ToInt32(reader["IdTipo"]), reader["RepreNombre"].ToString(), reader["AnyoEdicion"].ToString(), reader["Titulo"].ToString(), reader["Obs"].ToString());
                }
                
            }
            catch (Exception ex)
            {
                    throw new Exception("Se ha presentado un error al leer el Carro : " + ex.Message);
            }
            finally
            {
                if (null != reader && !reader.IsClosed)
                    reader.Close();
            }

            return Micarro;
        }
        

    }
Código:
//PAGINA carros.aspx.cs (en donde llamo a la clase)
protected void cargaDatos()
    {
        CARROS miCarro = new CARROS();
        miCarro = miCarro.LeeCarro(Convert.ToInt32(Request.QueryString["Id"]));


        cboTipo.SelectedValue = (Int32)miCarro.IdTipo;
        txtRepre.Text = miCarro.Representante;
        txtAnyoEdicion.Text = miCarro.Anyo_edicion;
        txtTitulo.Text = miCarro.Titulo;
        txtObs.Text = miCarro.Observaciones;

    }
Y como lo mencione arriba, el error que me da es el siguiente:

Cita:
No se puede convertir implícitamente el tipo 'int' en 'string'

Gracias de antemano.
__________________
"La adulación es una moneda que empobrece al que la recibe"