// Getting data from this Admin class:
public static IQueryable<Student> GetStudents()
{
DojoDBDataContext conn = new DojoDBDataContext();
var query =
from s in conn.Students
join b in conn.Belts on s.BeltID equals b.ID
orderby s.LastName ascending
select s;
return query;
}
// And on my form:
BindingSource bs = new BindingSource();
private void fillStudentGrid()
{
bs.DataSource = Admin.GetStudents();
dgViewStudents.DataSource = bs;
dgViewStudents.Columns.Remove("ID");
}
Works perfectly fine, but rather than removing 20+ columns of data that I don't want, I'd rather just add the few that I do. Plus, getting to name the header titles is a bonus. But, the add method isn't working for me:
private void fillStudentGrid()
{
bs.DataSource = Admin.GetStudents();
dgViewStudents.AutoGenerateColumns = false;
dgViewStudents.DataSource = bs;
dgViewStudents.Columns.Add("ID", "ID Number");
}
I get the appropriate number of rows, and the column title is set correctly... but the rows are filled with blank data.