你们中任何人都可以在stackoverflow上解释我为什么我的组合框没有显示任何项目。我有一个组合框从另一个获取值,因此它只显示特定项目,在这种情况下,项目是座位行。我试图设置一个breakpoit,看看它是否为null,而不是它得到正确的值。但由于某种原因,组合框不显示项目?你们任何人都可以帮助我吗?
这是第一个组合框selectIndex事件:
private void cbBookedSeatMovDate_SelectedIndexChanged(object sender, EventArgs e)
{
ServiceReferenceMovieRunTime.MovieRunTimeServiceClient movRunService = new ServiceReferenceMovieRunTime.MovieRunTimeServiceClient();
string _selectedMovName = Convert.ToString(cbBookedSeatMovInfo.SelectedValue);
string _selectedMovDate = Convert.ToString(cbBookedSeatMovDate.SelectedValue);
cbBookedSeatMovTime.DataSource = movRunService.GetRunTimeOnMovNameAndDate(_selectedMovName, _selectedMovDate);
cbBookedSeatMovTime.ValueMember = "id";
cbBookedSeatMovTime.DisplayMember = "startTime";
}
这是组合框事件不能正常工作:
private void cbBookedSeatMovTime_SelectedIndexChanged(object sender, EventArgs e)
{
ServiceReferenceMovieRunTime.MovieRunTimeServiceClient movRunService = new ServiceReferenceMovieRunTime.MovieRunTimeServiceClient();
ServiceReferenceSeats.SeatsServiceClient seatService = new ServiceReferenceSeats.SeatsServiceClient();
string _selectedMovTime = Convert.ToString(cbBookedSeatMovTime.SelectedValue);
string _selectedMovName = Convert.ToString(cbBookedSeatMovInfo.SelectedValue);
string _selectedMovDate = Convert.ToString(cbBookedSeatMovDate.SelectedValue);
string _runTimeId = Convert.ToString(movRunService.GetRunTimeOnNameDateAndTime(_selectedMovName, _selectedMovDate, _selectedMovTime));
cbRow1.DataSource = seatService.GetRowsOnRunTime(Convert.ToInt32(_runTimeId.First()));
cbRow1.ValueMember = "id";
cbRow1.DisplayMember = "rowId";
}
这是LINQ查询:
public List<TheaterSeat> GetRowsOnRunTime(int RunTime)
{
var queryResult = (from x in db.TheaterSeats
where x.runTime == RunTime
select x);
return queryResult.ToList();
}
希望你们能帮助我!