I have the following code:
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();
}
I get the error
System.NullReferenceException: Object reference not set to an instance of an object.
at the following code:
string [] seats = Request.Form[txtSeatNo.ClientID].Split(new char[] {','});
Please advise where I am wrong. I searched for various answers but cannot pinpoint where I am wrong.
Request.Form[txtSeatNo.ClientID]may give younull???