Hola!
Tengo un DropDownList que lleno con los datos de un StoredProcedure de SQL, pero siempre se "come" el primer registro del resultado del stored, no que se que esté pasando.. aqui esta mi código...
Código:
SqlConnection sqlConexionGral = null;
SqlCommand sqlComandoGral = null;
SqlDataReader rsGral = null;
string strConnGral = System.Configuration.ConfigurationSettings.AppSettings["Conexion"];
sqlConexionGral = new SqlConnection((String) strConnGral);
sqlComandoGral = new SqlCommand();
// Abrirmos la conexion
sqlConexionGral.Open();
// Comenzamos a preparar los comandos
sqlComandoGral.Connection = sqlConexionGral;
// Comenzamos a preparar los comandos
sqlComandoGral.CommandText = " LstPais";
sqlComandoGral.CommandType = CommandType.Text;
rsGral=sqlComandoGral.ExecuteReader();
if (rsGral !=null && rsGral.HasRows )
{
if (rsGral.Read())
{
ddlPais.DataSource = rsGral;
ddlPais.DataTextField = "Nombre";
ddlPais.DataValueField = "PaisId";
ddlPais.DataBind();
if (!PaisId.Equals("0"))
{
ddlPais.Items.FindByValue(PaisId).Selected = true;
}
}
}
Heeeelp!!!