C sharp - selected value de un DropDownList dentro de un gridview

 
Vista:
sin imagen de perfil

selected value de un DropDownList dentro de un gridview

Publicado por jose manuel (5 intervenciones) el 20/07/2016 00:25:49
Espero me puedan ayudar, al llenar un DropDownList dentro de un grid view este se ejecuta bien, pero ahora necesito que al finalizar cada linea este DropDownList tenga su valor asignado desde una tabla el DropDownList puede venir con 4 campos por decirlo asi oaxaca, leon, merida y quiero que al llenar el grid cada DropDownList este seleccionado su valor por linea

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
protected void gridTrenes_RowDataBound(object sender, GridViewRowEventArgs e)
{
 
	if (e.Row.RowType == DataControlRowType.DataRow)
	{
		//Find the DropDownList in the Row
		// DropDownList ddlCountries = (e.Row.FindControl("drpDestinos") as DropDownList);
 
		DropDownList ddlCountries = (DropDownList)e.Row.FindControl("drpDestinos");
		TextBox Llegada = (e.Row.FindControl("txtLlegadaGrid") as TextBox);
		TextBox Liberacion = (e.Row.FindControl("txtLiberacionGrid") as TextBox);
		TextBox Salida = (e.Row.FindControl("txtSalidaGrid") as TextBox);
		Button Guardar = (e.Row.FindControl("GuardarGridBtn") as Button);
 
		drpDestinos.DataSource = SIPP.DataBase.GetTable("despachos.dbo.sp_OrigenesGet");
		drpDestinos.DataTextField = "descripcion";
		drpDestinos.DataValueField = "Origen";
		drpDestinos.DataBind();
 
 
		if (Liberacion.Text != "" && Salida.Text !="")
		{
			ddlCountries.Enabled = false;
			Guardar.Enabled = false;
			Llegada.Enabled = false;
			Liberacion.Enabled = false;
			Salida.Enabled = false;
		}
 
	}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

selected value de un DropDownList dentro de un gridview

Publicado por Lady Garay Gutierrez (2 intervenciones) el 25/07/2016 07:15:27
Yo tengo algo así, espero te sirva, aquí lo agrego:
1
entTrab.IdDepartamento = ((EntityCatalogos)this.cmbDepartamento.SelectedItem).Id;
Y con este metodo hago que se visualice el que ya estaba seleccionado:
1
2
3
4
5
6
7
8
9
10
11
private void mostarDatos(EntityTrabajador _trab)
        {
            try
            {
                this.cmbDepartamento.SelectedIndex = _trab.IdDepartamento;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex + "");
            }
        }
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar