我正在尝试制作一个预订系统,我可以在其中从 LINQ 中的列表中获取数据,并将其显示在一系列文本框中,但我遇到了问题,因为当我运行程序时它只显示数字 1。
这是我的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
namespace BookingCustomers
{
public partial class BookingGuests : System.Web.UI.Page
{
private HotelConferenceEntities datacontext = new HotelConferenceEntities();
private void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
int id = int.Parse(BookID.Text.ToString());
tblBooking booking = datacontext.tblBookings.SingleOrDefault(x => x.BookingID == id);
tblVenue venue = datacontext.tblVenues.SingleOrDefault(x => x.VenueID == booking.Venue);
List<tblCustomer> customers = new List<tblCustomer>();
List<tblBookingGuest> guests = booking.tblBookingGuests.ToList();
foreach (tblBookingGuest guest in guests)
{
tblCustomer newcust = datacontext.tblCustomers.SingleOrDefault(x=>x.CustomerID == guest.CustomerID);
customers.Add(newcust);
}
int count = customers.Count;
//string table=string.Join(",",customers);
int [] displayer={customers.Count};
int max=(displayer.Max());
CustFirstName.Text =displayer.Where(p=> p== max).Count().ToString();