hi can anybudy temme the reason of this error

my code is

DataClassesDataContext dc = new DataClassesDataContext();
 tblUser tu = new tblUser();
           
            var res = (from p in dc.tblUsers where p.nUserID == _index select p).FirstOrDefault();
           

            res.strUserName = txtUserName.Text;
            res.strPassword = txtPassword.Text;
            res.dAddDate = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            res.bIsDeleted = false;

it is giving me dis exception on

res.strUserName = txtUserName.Text;

why its so:((

Check the null.

var res = (from p in dc.tblUsers where p.nUserID == _index select p).FirstOrDefault();
           
 if(res!=null)
  {
            res.strUserName = txtUserName.Text;
            res.strPassword = txtPassword.Text;
            res.dAddDate = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            res.bIsDeleted = false;
  }