0

I'm trying tomake a booking system where I can get data from a list in LINQ, and display it in a series of textboxes but I'm having problems as when I run the program it simply displays the number 1.

this is my code

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();
Furkan Ekinci
  • 2,472
  • 3
  • 29
  • 39
Captain_Custard
  • 1,308
  • 6
  • 21
  • 35
  • 7
    And what would you expect? You're doing a `Count()` that's always a number, in this case, 1 – Claudio Redi May 30 '13 at 12:49
  • 2
    This is a duplicate question. http://stackoverflow.com/q/16835614/263681. You can edit your original. Please don't repost questions, and it's especially terrible when the second form is just as bad as the first. – Grant Thomas May 30 '13 at 12:56

0 Answers0