我有以下代码:
protected void btnSave_Click(object sender, EventArgs e)
{
StarBusModel.BookingDetail1 objBooking = new StarBusModel.BookingDetail1();
objBooking.TourID = tourID;
objBooking.Name = txtName.Text;
objBooking.Phone = txtPhone.Text;
objBooking.Amount = Convert.ToDecimal(Request.Form[txtAmount.ClientID]);
string [] seats = Request.Form[txtSeatNo.ClientID].Split(new char[] {','});
for (int i = 0; i < seats.Length; i++)
objBooking.SeatDetails.Add(new StarBusModel.SeatDetail1() {SeatID = Convert.ToInt32(seats[i])});
objEntities.BookingDetail1.AddObject(objBooking);
objEntities.SaveChanges();
BindSeats();
}
我得到错误
System.NullReferenceException: Object reference not set to an instance of an object.
在以下代码中:
string [] seats = Request.Form[txtSeatNo.ClientID].Split(new char[] {','});
请告知我哪里错了。我搜索了各种答案,但无法确定我错在哪里。