Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/05/2006, 08:34
Emerald
 
Fecha de Ingreso: mayo-2006
Mensajes: 243
Antigüedad: 17 años, 11 meses
Puntos: 0
Pregunta C# Llenar y Mostrar un DataGrid

Hola!

Quisiera que al dar click en un boton me llene un DataGrid, pero no me está mostrando el datagrid, no se por qué??

Primero agregué el DataGrid a mi form y lo llame: dgEmpresas y un botón de buscar: btBuscar

Este es mi código:

Código:
private void btnBuscar_Click(object sender, System.EventArgs e)
		{
			string strConexion = this._appconfig.GetConfig("Conexiones","ContenidoPrueba");
			FillDataGrid(this.ddlRamo.SelectedValue,this.ddlCategoria.SelectedValue, strConexion);
		}

		private void FillDataGrid(string vRamo, string vCategoria, string strConexion)
		{
			string vPalabra = null;
			int vTipo = 1;
			SqlConnection sqlConexion = null;	 
			SqlCommand sqlComando = null; 
			// Creamos la conexión
			sqlConexion	= new SqlConnection(strConexion);
			sqlComando = new SqlCommand("LstEmpresas " + vRamo + vCategoria + vPalabra + vTipo , sqlConexion);
			try 
			{
				sqlConexion.Open();
				SqlDataAdapter da = new SqlDataAdapter(sqlComando);
				//Llenar el Dataset
				DataSet ds = new DataSet();
				da.Fill(ds, "Empresas");
				//Configurar el DatGrid
				DataGrid dgEmpresas = new DataGrid();
				Page.Controls.Add(dgEmpresas);
				//Ligar el datagrid con la fuente de datos
				dgEmpresas.DataSource = ds;
				dgEmpresas.DataMember = "Empresas";
				dgEmpresas.DataBind();
			} // try
			
			catch // (Exception e) // Exception Removed
			{
				return;
				//throw new Exception("Error in FillDropDownLit -> " + e.ToString());
			} // catch
			finally
			{
				sqlComando.Dispose();
				sqlConexion.Close();    // Close Connection
				sqlConexion.Dispose();  
			}
			return;
		}
	}
No se por que no me muestra el DataGrid

... Me faltó comentar que cuando le doy click al botón me marca el siguiente error:

Directory Listing Denied
This Virtual Directory does not allow contents to be listed.

Última edición por Emerald; 25/05/2006 a las 08:58