Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/12/2010, 07:53
eloy_ameneiros
 
Fecha de Ingreso: julio-2010
Mensajes: 93
Antigüedad: 13 años, 10 meses
Puntos: 0
Cargar Gridview desde SQL

Hola a todos, el proble que tengo es que quiero cargar un gridview que tengo en una página asp con una consulta SQL. Tengo el siguiente código que creo que está bien, pero cuando cargo la página no me muestra ni el gridview.

public partial class Verificacion : System.Web.UI.Page
{
SqlConnection conexionSQL = new SqlConnection(@"Data Source = WALLPT; Initial Catalog = VENTAS; Persist Security Info = True; User ID = intranet; Password = iserv2010");

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.CargarGrid();
}
}

protected void CargarGrid()
{
SqlDataAdapter da;
string Cgrid = @"SELECT * FROM Verificacion WHERE Finalizada = 'NO'";
try
{
DataTable dt = new DataTable();
da = new SqlDataAdapter(Cgrid, conexionSQL);
conexionSQL.Open();
da.Fill(dt);
gv_verificar.DataSource = dt;
gv_verificar.DataBind();
conexionSQL.Close();
}
catch
{
Response.Redirect("Error.aspx");
}
finally
{
if (conexionSQL.State == ConnectionState.Open)
{
conexionSQL.Close();
}
}

}
}

Les agradezco cualquier ayuda posible, ya que llevo un par de días y no consigo solucionarlo.

Gracias.