I have this datatable, which will display the values from the database.
private void CreateTable() {
dt = new DataTable();
dt.Columns.Add("ScheduleID", typeof(int));
dt.Columns.Add("Username", typeof(string));
dt.Columns.Add("Subject", typeof(string));
dt.Columns.Add("Description", typeof(string));
... }
I’m using this code, and there are no errors but I don’t know why the values aren’t showing up. Any help? Thanks.
dgvSchedule.DataSource = new DataView(dt, "Username = '" + lblUsername.Text + "' and Subject = '" + cbxSubject.Text + "'", "Subject", DataViewRowState.CurrentRows);
I post my answer here, for readability.
If dt is your datatable, then you can do something like this