【发布时间】:2021-12-05 17:38:08
【问题描述】:
我正在尝试绑定 2 个组合框,作为 de first 的第二个依赖项的值。
我看到这个问题的所有解决方案都是使用 Sql.Data (Datatable),但由于应用程序的体系结构,我无法使用它。
我可以通过 C# 或通过 ASP 对象数据源两种方式来实现。 我已经成功地尝试了这种方法。可以这样做吗?
if (!Page.IsPostBack)
{
recursohumano rh = new RecursoHumano();
rdpUnidade.DataValueField= "ID"
rdpUnidade.DataTextField= "NomeUnidade"
rdpUnidade.DataSource= new BLLUnidade().GetAll();
rdpUnidade.DataBind();
rdpInvestigador.DataValueField= "ID"
rdpInvestigador.DataTextField= "Nome"
rdpInvestigador.DataSource= new BLLRecursoHumano().GetAll();
rdpInvestigador.DataBind();
rdpInvestigador.Items.Insert(0, new RadComboBoxItem("", ""));
//rdp investigador should depend on rdpUnidade
private void rdpUnidade_SelectedIndexChanged(object sender, EventArgs e)
{
recursohumano rh = new RecursoHumano();
var InvUnidade = from recursohumano in rh.recursohumano where recursohumano.id == Convert.ToInt32(rdpUnidade.SelectedValue) select recursohumano;
rdpInvestigador.DataValueField= "ID";
rdpInvestigador.DataTextField= "Nome";
rdpInvestigador.DataSource = new BLLRecursoHumano().GetAll()
}
【问题讨论】:
标签: c# sql asp.net combobox objectdatasource