First of all sorry for so many questions that for many of you must be insignificant things I imagine, (apprentice mistakes say) The subject is like this: I have properties, each property has date ranges (start date and end date) I did the following in 2 different ways to test if there was something wrong with it and I missed the following error: "The input string it does not have the correct format "
Next I put the code so they can see. In the mapper of properties I did it this way.
public List<Propiedad> obtenerRangosPorIdPropiedad(int xIdPropiedad)
{
List<Propiedad> listaPropiedades= new List<Propiedad>();
var param = new List<SqlParameter>();
var idPropiedad = new SqlParameter();
idPropiedad .ParameterName = "@idPropiedad ";
idPropiedad .Value = xIdPropiedad;
param.Add(idPropiedad );
var conn = abrirConexion();
var r = @select("SELECT * FROM Propiedad p JOIN Rango r ON r.idPropiedad = a.idPropiedad WHERE idPropiedad= @idPropiedad", CommandType.Text, param, conn, null);
while(r.Read())
{
listaPropiedades.Add(CargarPropiedad(r));
}
cerrarConexion(conn);
return listaPropiedades;
}
In the services part I did it in this other way:
public List<Rango> obtenerRangosDePropiedades(int xIdPropiedad)
{
List<Rango> listaRangos = obtenerTodosLosRangos();
List<Rango> rangosFiltrados = new List<Rango>();
foreach(var objR in listaRangos)
{
if(objR.propiedad.idPropiedad == xIdPropiedad)
{
rangosFiltrados.Add(objR);
}
}
return rangosFiltrados;
}
And here is where I get the error, in the codebehind I do the following:
In the load I call a method that does this
private void cargarRangos()
{
lstRangos.DataSource = new GestoraRango().obtenerRangosDePropiedades(Convert.ToInt32(lstPropiedades.SelectedValue)); //En esta línea me tira ese error.
lstRangos.DataTextField = "datos";
lstRangos.DataValueField = "idRango";
lstRangos.DataBind();
}
Thanks in advance.