<textarea id="TextAreaSend" runat="server" name="SendText">
I created text area to write something.And will save it to database with linq to entity.
if (!String.IsNullOrEmpty(TextAreaSend.InnerText))
{
int ticketno = Convert.ToInt32(ViewState["TicketNo"]);
var source = from tickettext in entities.Tickets
where tickettext.TicketNo == ticketno
select tickettext;
Ticket ticket = source.Single();
//This is where null point exception is
ticket.Answer.AnswerText = TextAreaSend.InnerText;
entities.SaveChanges();
}
ticket.Answer.AnswerText = TextAreaSend.InnerText; In this line i receive;
Object reference not set to an instance of an object.Why is that? How can i fix it?