When running the following code I get the exception "System.Nullreferenceexception:object reference not set to an instance of an object". I believe it has something to with not initializing the allStudents variable but I'm not sure what type allStudents is.
Any help is appreciated
    private void showStudents(string c)
    {
        try
        {
            using (SMDataClassesDataContext db = new SMDataClassesDataContext())
            {
                var allStudents = from t in db.tbl_students
                                  where t.current_class == c
                                  select t;
              dgViewStudents.ItemsSource = allStudents;
            }
        }
        catch (Exception e)
        {
            MessageBox.Show(e.ToString());
        }
    }
 
    