Ver Mensaje Individual
  #2 (permalink)  
Antiguo 19/09/2006, 17:08
Emerald
 
Fecha de Ingreso: mayo-2006
Mensajes: 243
Antigüedad: 18 años
Puntos: 0
he decidido hacer un llenado aparte para el checkboxlist.

de la siguiente manera:

Código:
SqlConnection sqlConexion = null;   
SqlCommand sqlComando = null; 
SqlDataReader rs = null;
try
{
	// Creamos la conexión
	string strConn = System.Configuration.ConfigurationSettings.AppSettings["MyConexion"];
	sqlConexion = new SqlConnection((String) strConn);
	sqlComando = new SqlCommand();
	// Abrirmos la conexion
	sqlConexion.Open();
		
	// Comenzamos a preparar los comandos
	sqlComando.Connection = sqlConexion;
	sqlComando.CommandText = "LstBusqNoticias " + Ciudad + ", " + TituloText + ", " + TituloText +  ", " + IdNoticia;
	sqlComando.CommandType = CommandType.Text;
	rs=sqlComando.ExecuteReader();

	if(rs.HasRows)
	{
		ChkNoticia.DataSource = rs;
		ChkNoticia.DataTextField = "titulo";
		ChkNoticia.DataValueField="id_noticia";
		ChkNoticia.DataBind();
	}
pero me marca el siguiente error:

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

Source Error:


Line 1362: if(rs.HasRows)
Line 1363: {
Line 1364: ChkNoticia.DataSource = rs;
Line 1365: ChkNoticia.DataTextField = "titulo";
Line 1366: ChkNoticia.DataValueField="id_noticia";


Source File: c:\documents and settings\my documents\visual studio projects\fisherproject\alta_modifica_programacion. aspx.cs Line: 1364

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
FisherProject.alta_modifica_programacion.LlenaChec kBox() in c:\documents and settings\my documents\visual studio projects\fisherproject\alta_modifica_programacion. aspx.cs:1364
FisherProject.alta_modifica_programacion.BuscarNot iciaButton_Click(Object sender, ImageClickEventArgs e) in c:\documents and settings\my documents\visual studio projects\fisherproject\alta_modifica_programacion. aspx.cs:553
System.Web.UI.WebControls.ImageButton.OnClick(Imag eClickEventArgs e)
System.Web.UI.WebControls.ImageButton.System.Web.U I.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain() +1292