Foros del Web » Programando para Internet » ASPX (.net) »

Object reference not set to an instance of an object. pagina asp

Estas en el tema de Object reference not set to an instance of an object. pagina asp en el foro de ASPX (.net) en Foros del Web. Buenas tardes soy nuevo en el foro espero este pub licando en el lugar correcto mi problema es el siguiente: Exception Details: System.NullReferenceException: Object reference ...
  #1 (permalink)  
Antiguo 30/04/2009, 17:00
 
Fecha de Ingreso: abril-2009
Mensajes: 16
Antigüedad: 15 años
Puntos: 0
Object reference not set to an instance of an object. pagina asp

Buenas tardes soy nuevo en el foro espero este pub licando en el lugar correcto mi problema es el siguiente:

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

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
uc_ucDetalleMiReserva.LlenarComboPagos(DropDownLis t ddlFormaPago) +52
uc_ucDetalleMiReserva.CargarReserva() +1852
uc_ucDetalleMiReserva.Page_Load(Object sender, EventArgs e) +164
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

Si alguien tiene alguna idea de por que sale el error me podria comentar para poner el resto del codigo sobre el cual genera el error gracias
  #2 (permalink)  
Antiguo 30/04/2009, 17:09
 
Fecha de Ingreso: octubre-2000
Mensajes: 1.692
Antigüedad: 23 años, 5 meses
Puntos: 19
Respuesta: Object reference not set to an instance of an object. pagina asp

podrías pegar el código de tu aplicacion donde se genera ese error?
__________________
PD: Con amor, fe, amor a Dios y amistad podemos hacer un mundo mejor!!!!
  #3 (permalink)  
Antiguo 30/04/2009, 17:17
 
Fecha de Ingreso: abril-2009
Mensajes: 16
Antigüedad: 15 años
Puntos: 0
Respuesta: Object reference not set to an instance of an object. pagina asp

ok gracias por contestar es un control de usuario lo que sale en negrilla es de donde me saca el error.
protected void CargarReserva()
{
int decide = Convert.ToInt32(Request.QueryString["intdecide"]);
string strLocalizador = Request.QueryString["strLocalizador"].ToString();
int intEstado = Convert.ToInt32(Request.QueryString["intEstado"]);
int intvencer = Convert.ToInt32(Request.QueryString["intvencer"]);
strRefereTipoServicio = Request.QueryString["strRefereTipoServicio"];
csRules.strConexion = ConfigurationManager.AppSettings["strConexion"].ToString();
DataTable dt = new DataTable();
DataTable dtgv = new DataTable();
if (intvencer == 1)
{
imgConfirmarPago.Visible = true;
dt = csRules.ConsultaDetallesTodos(strLocalizador);
rptReserva.DataSource = dt.DefaultView;
rptReserva.DataBind();

for (int i = 0; i < rptReserva.Items.Count; i++)
{
dt = csRules.ConsultaDetallesTodos(strLocalizador, ((Label)(rptReserva.Items[i].Controls[3])).Text, ((Label)(rptReserva.Items[i].Controls[5])).Text);
((Repeater)(rptReserva.Items[i].Controls[9])).DataSource = dt.DefaultView;
((Repeater)(rptReserva.Items[i].Controls[9])).DataBind();
int iContar = ((Repeater)(rptReserva.Items[i].Controls[9])).Items.Count;
if (iContar > 0)
iContar = iContar - 1;
for (int j = 0; j < ((Repeater)(rptReserva.Items[i].Controls[9])).Items.Count; j++)
{

Repeater rptPlanes3 = (Repeater)(rptReserva.Items[i].Controls[9]);
Label lblStrReferTipoServicio = (Label)rptPlanes3.Items[j].Controls[70];
lblStrReferTipoServicio.Text = this.strRefereTipoServicio;
if (decide == 2)
{
Panel pnlPago = (Panel)rptPlanes3.Items[j].Controls[60];
DropDownList ddlFormaPago = (DropDownList)pnlPago.Controls[7];
LlenarComboPagos(ddlFormaPago);

}
if (decide == 2 || decide == 3 || decide == 4 || decide == 5 || decide == 6)
{
Repeater rptPlanes = (Repeater)(rptReserva.Items[i].Controls[9]);
Label lablrecord = (Label)rptPlanes.Items[j].Controls[52];
lablrecord.Visible = false;
TextBox txtRecord = (TextBox)rptPlanes.Items[j].Controls[54];
txtRecord.Visible = false;
Label lblNombre = (Label)rptPlanes.Items[j].Controls[56];
lblNombre.Visible = false;
TextBox txtNombre = (TextBox)rptPlanes.Items[j].Controls[58];
txtNombre.Visible = false;
}
if (decide == 1 || decide == 3 || decide == 4 || decide == 5)
{
Repeater rptPlanes = (Repeater)(rptReserva.Items[i].Controls[9]);

Panel pnlConfirmaPago = (Panel)(rptPlanes.Items[j].Controls[60]);
pnlConfirmaPago.Visible = false;
}
Repeater rptPlanes2 = (Repeater)(rptReserva.Items[i].Controls[9]);
Label lblEstado = (Label)rptPlanes2.Items[j].Controls[34];
if (lblEstado.Text == "Canceladas" || lblEstado.Text == "Cerradas")
{

Repeater rptPlanes = (Repeater)(rptReserva.Items[i].Controls[9]);
Label lblCancelar = (Label)rptPlanes.Items[j].Controls[50];
lblCancelar.Visible = false;
CheckBox chkCancelar = (CheckBox)rptPlanes.Items[j].Controls[48];
chkCancelar.Visible = false;
}


if (lblEstado.Text == "Canceladas" || lblEstado.Text == "Cerradas" || lblEstado.Text == "Confirmadas" || lblEstado.Text == "Pagadas")
{

Repeater rptPlanes = (Repeater)(rptReserva.Items[i].Controls[9]);
Label lablrecord = (Label)rptPlanes.Items[j].Controls[52];
lablrecord.Visible = false;
TextBox txtRecord = (TextBox)rptPlanes.Items[j].Controls[54];
txtRecord.Visible = false;
Label lblNombre = (Label)rptPlanes.Items[j].Controls[56];
lblNombre.Visible = false;
TextBox txtNombre = (TextBox)rptPlanes.Items[j].Controls[58];
txtNombre.Visible = false;
}
if (lblEstado.Text == "Canceladas" || lblEstado.Text == "Cerradas" || lblEstado.Text == "Solicitadas" || lblEstado.Text == "Pagadas")
{

Repeater rptPlanes = (Repeater)(rptReserva.Items[i].Controls[9]);

Panel pnlConfirmaPago = (Panel)(rptPlanes.Items[j].Controls[60]);
pnlConfirmaPago.Visible = false;


}
if (iContar == j)
{
dtgv = csRules.ConsultaDetallesPax(((Label)(rptReserva.It ems[i].Controls[7])).Text, ((Label)(rptReserva.Items[i].Controls[5])).Text);
((GridView)(((Repeater)(rptReserva.Items[i].Controls[9])).Items[j].Controls[46])).DataSource = dtgv.DefaultView;
((GridView)(((Repeater)(rptReserva.Items[i].Controls[9])).Items[j].Controls[46])).DataBind();
}
else
{
((Label)(((Repeater)(rptReserva.Items[i].Controls[9])).Items[j].Controls[44])).Visible = false;
}
}
}

}
}
  #4 (permalink)  
Antiguo 30/04/2009, 17:26
 
Fecha de Ingreso: octubre-2000
Mensajes: 1.692
Antigüedad: 23 años, 5 meses
Puntos: 19
Respuesta: Object reference not set to an instance of an object. pagina asp

Hola.

No se ve donde sale el error, no veo negrillas.
De todos modos este error te lo sule dar cuando estas accediendo a un indice de un control que no existe. Fijate si podes señalar bien donde te da el error
__________________
PD: Con amor, fe, amor a Dios y amistad podemos hacer un mundo mejor!!!!
  #5 (permalink)  
Antiguo 30/04/2009, 19:55
 
Fecha de Ingreso: abril-2009
Mensajes: 16
Antigüedad: 15 años
Puntos: 0
Respuesta: Object reference not set to an instance of an object. pagina asp

que pena olvide poner las negrilas es exactamente en las lineas 35 y 36, DropDownList ddlFormaPago = (DropDownList)pnlPago.Controls[7];
LlenarComboPagos(ddlFormaPago);
creo que no todas las veces ese control va a venir debido a las necesidades de mi aplicacion por eso creo q me bota el error pero aun tengo dudas
  #6 (permalink)  
Antiguo 01/05/2009, 08:43
 
Fecha de Ingreso: octubre-2000
Mensajes: 1.692
Antigüedad: 23 años, 5 meses
Puntos: 19
Respuesta: Object reference not set to an instance of an object. pagina asp

Hola
Si, como te comente es porque algo no está encontrando. Ahí cuando crees el objeto despues y antes de usarlo vas a tener que preguntar si es distinto de nulo para acceder a ese objeto:

DropDownList ddlFormaPago = (DropDownList)pnlPago.Controls[7];
if(ddlFormaPago!=null)
{
// codigo...
}
__________________
PD: Con amor, fe, amor a Dios y amistad podemos hacer un mundo mejor!!!!
  #7 (permalink)  
Antiguo 01/05/2009, 10:54
 
Fecha de Ingreso: abril-2009
Mensajes: 16
Antigüedad: 15 años
Puntos: 0
Respuesta: Object reference not set to an instance of an object. pagina asp

listo compa hice lo que hice pero me siguio sacando el error pero ya lo detecte era una conexion que estaba estableciendo a una base de datos que no existia.....
ahora me saco..... es el sgte:

Access to the path 'C:\Tablas\.html' is denied.

creo que tengo que darle click derecho en la carpeta seguridad y adicionarle permisos al usuario ISS o ASP.NET no estoy seguro ....me podrian colaborar gracisasss
  #8 (permalink)  
Antiguo 01/05/2009, 19:05
 
Fecha de Ingreso: octubre-2000
Mensajes: 1.692
Antigüedad: 23 años, 5 meses
Puntos: 19
Respuesta: Object reference not set to an instance of an object. pagina asp

asegurate primero que el nombre del fichero exista. Para configurar permisos y eso mira acá que explican como hacerlo detalladamente, a lo mejor te sirve:

http://www.forosdelweb.com/f29/no-pu...porque-200699/

Cualquier cosa avisa.
__________________
PD: Con amor, fe, amor a Dios y amistad podemos hacer un mundo mejor!!!!
  #9 (permalink)  
Antiguo 03/05/2009, 15:05
 
Fecha de Ingreso: abril-2009
Mensajes: 16
Antigüedad: 15 años
Puntos: 0
Respuesta: Object reference not set to an instance of an object. pagina asp

ok amigo muchas gracias, ya pude solucionar gracias por contestar
  #10 (permalink)  
Antiguo 11/04/2010, 11:22
 
Fecha de Ingreso: abril-2008
Mensajes: 3
Antigüedad: 16 años
Puntos: 1
Respuesta: Object reference not set to an instance of an object. pagina asp

Que tal, puedes compartir como solucionaste el error:

Código:
[NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.]
   Aspx_00_e00Login.Page_Load(Object sender, EventArgs e) +740
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Adapters.ControlAdapter.OnLoad(EventArgs e) +15
   System.Web.UI.Control.LoadRecursive() +8683053
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:12.