Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/11/2010, 05:18
dikcc
 
Fecha de Ingreso: junio-2010
Mensajes: 134
Antigüedad: 13 años, 10 meses
Puntos: 0
Insertar DropDownList en DataTable

Buenos días,

Necesito insertar un DDL en un DataTable para luego poder mostrar dicho DDL en un GridView.

Haciendo esto:

DataSet ds2 = mL.ManagerListViewRellenarLiqFil(9, 2010);
ddl.DataSource = ds2.Tables[0];
ddl.DataTextField = "TipoLiqui";
ddl.DataValueField = "TipoLiqui";
ddl.DataBind();

DataTable dt = new DataTable();
dt.Columns.Add(Convert.ToString(Session["Nombre"]));

DataRow dr = dt.NewRow();

dr[0] = new DropDownList();

((DropDownList)dr[0]).DataSource = ddl.DataSource;
((DropDownList)dr[0]).DataTextField = ddl.DataTextField;
((DropDownList)dr[0]).DataValueField = ddl.DataValueField;
((DropDownList)dr[0]).DataBind();

dt.Rows.Add(dr);

Se inserta System.Control.DropDownList o algo así, y es lo que muestra el GridView al pones como DataSource el DataTable.

¿Alguien sabe como hacerlo?