Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/05/2009, 14:40
Avatar de Dradi7
Dradi7
 
Fecha de Ingreso: junio-2008
Ubicación: Peru - Lima
Mensajes: 1.518
Antigüedad: 15 años, 11 meses
Puntos: 220
Respuesta: Como separar una cadena de un combobox

y porque no separas en tu consulta el codigo tanto como el nombre para que puedas usar el selectedvalue y tomar el codigo sin problemas

ejm:

Código C#:
Ver original
  1. SqlConnection Con = SqlConnection("tu conexion");
  2. SqlDataAdapter Adp;
  3. DataSet Ds = new DataSet();
  4. SqlCommand Com = new SqlCommand();
  5. Con.Open();
  6. Com.Connection = Con;
  7. Com.CommandType = CommandType.Text;
  8. Com.CommandText = "Select Codigo,Nombre From TuTabla";
  9. Adp = new SqlDataAdapter(Com);
  10. Adp.fill(Ds,"x");
  11.  
  12. ComboBox1.DataSource = Ds.Tables["x"];
  13. ComboBox1.DisplayMember = "Nombre";
  14. ComboBox1.ValueMember = "Codigo";
  15. //con la propiedad SelectedValue Tomas el valor del item seleccionado
  16. ComboBox1.SelectedValue();
__________________
La clave de todo triunfador es eliminar todas sus excusas y sus limitaciones