我是.NET新手开发人员,所以遇到了问题。我需要根据另一个依赖第一个的选择来自动选择一个下拉菜单。实际上,就像我在选择城市时需要自动选择州一样。授予1个城市与1个州的关系。
在我的情况下,等级关系是:设施->驾驶员->卡车,一辆卡车属于一名特定的驾驶员,但是一名驾驶员可以配发许多卡车。
DDL的填充是使用LINQ进行的,因此我必须保留这个概念。
这是这样的:
private void CargarComboCamionesRepartos()
{
var listaCamionesRepartos = (from oc in TMS.Operacion_Camion
join of in (
from u in TMS.Usuarios
join ou in TMS.Operaciones_Usuario
on u.Usuario
equals ou.Usuario
join o in TMS.Operaciones
on ou.Nro_Operacion
equals o.Nro_Operacion
where (u.Usuario == Usuario.Name && (ou.Nro_Operacion.ToString() == ddlOperacionesPlantas.SelectedValue || ddlOperacionesPlantas.SelectedValue == "0"))
select new { ou.Nro_Operacion, o.Nic })
on oc.Nro_Operacion
equals of.Nro_Operacion
join c in TMS.Camiones
on oc.Nro_Camion
equals c.Nro_Camion
where (c.Cod_Transp.ToString() == ddlTransportistasFleteros.SelectedValue || ddlTransportistasFleteros.SelectedValue == "0")
select new {c.Nro_Camion, c.Patente}
)
.Distinct().OrderBy(x => x.Patente);
ddlCamionesRepartos.DataSource = listaCamionesRepartos.ToList();
ddlCamionesRepartos.DataValueField = "Nro_Camion";
ddlCamionesRepartos.DataTextField = "Patente";
ddlCamionesRepartos.DataBind();
ddlCamionesRepartos.Items.Insert(0, new ListItem("Todos", "0"));
ddlCamionesRepartos.SelectedIndex = 0;
}
感谢您的帮助。