Skip to content

Instantly share code, notes, and snippets.

@jofese
Created July 6, 2017 14:54
Show Gist options
  • Select an option

  • Save jofese/aac798ef85da59f3599e15596ba0d98a to your computer and use it in GitHub Desktop.

Select an option

Save jofese/aac798ef85da59f3599e15596ba0d98a to your computer and use it in GitHub Desktop.
Llenar un combobox por dataset c#
public void LlenarComboMotivos()
{
try
{
//this.cbMotivo.Items.Clear();
this.cbMotivo.DataSource = null;
OracleDataAdapter daEmp = new OracleDataAdapter("select IDMOT, MOTNUM||' : '||MOT AS MOT, MOTNUM, FECREG, USENAM, HOSTNAME from SIA_MOTIVOS order by MOTNUM asc", cls_DatosLolcli.cadenaconexion);
DataSet dsEmp = new DataSet("SIA_MOTIVOS");
daEmp.Fill(dsEmp, "SIA_MOTIVOS");
DataTable dtEmp = dsEmp.Tables["SIA_MOTIVOS"];
DataRow[] drEmp = dsEmp.Tables["SIA_MOTIVOS"].Select();
if (dsEmp.Tables[0].Rows.Count > 0)
{
this.cbMotivo.DataSource = dsEmp.Tables[0].DefaultView;
this.cbMotivo.DisplayMember = "MOT";
this.cbMotivo.ValueMember = "MOTNUM";
}
}
catch (Exception ex)
{
throw;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment