0
我需要ddlstore_selectedindexchange事件下的代碼幫助。我試圖讓員工和客戶清單自動檢查他們的外鍵ID是否等於商店主鍵ID。我無法弄清楚如何在IF語句中輸入內容。我選擇了包含相關主鍵的下拉列表項目後自動選擇覈對清單項目
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
using (StuffContainer context = new StuffContainer())
{
ddlstore.DataSource = context.Stores.ToList();
ddlstore.DataTextField = "Name";
ddlstore.DataValueField = "Id";
ddlstore.DataBind();
chkemp.DataSource = context.Customers.ToList();
chkemp.DataTextField = "FName";
chkemp.DataValueField = "Id";
chkemp.DataBind();
chkcust.DataSource = context.Employees.ToList();
chkcust.DataTextField = "FName";
chkcust.DataValueField = "Id";
}
}
}
protected void ddlstore_SelectedIndexChanged(object sender, EventArgs e)
{
int storeId = int.Parse(ddlstore.SelectedValue);
using (StuffContainer context = new StuffContainer())
{
List<Employee> employees = context.Employees.ToList();
var employee = context.Employees.Where(x => x.StoreId == storeId);
foreach(Employee item in employees)
{
if()
{
}
}
}
}
就像一個魅力。你是男人。 – fangalang