Hi:
I have a datagridview that i'm trying to populate with a datatable that was filled with values from sql server. There are 8 columns in the datagridview with two of the columns having checkboxes. When I put in my code,
if (dt.Rows.Count > 0 && dt != null)
{
dataGridView.DataSource = dt;
}
I get nothing. Before I had the checkboxes, I had no problem with loading the data.
How do you assign the datatable columns to the proper column of the datagridview?
Also, I created my datagridview in the program _Load part of my code. Should I create the columns there as well, if the data is not loaded until a certain button is clicked later on?
column 1 is a checkboxcolumn
column 2 is an ID number
column 3 is a Holiday name
column 4 is Day of week
column 5 is Month
column 6 is Day
column 7 is the year
column 8 is another checkboxcolumn
The datagridview columns are shown below. Right after Naming the first and last columns, I add a Checkbox to it.
dataGridView.Columns[0].Name = "Holiday Approval";
AddCheckBoxForDataGridView(dataGridView, "Holiday Approval");
dataGridView.Columns[1].Name = "Holiday ID";
dataGridView.Columns[2].Name = "Holiday";
dataGridView.Columns[3].Name = "Day of Week";
dataGridView.Columns[4].Name = "Month";
dataGridView.Columns[5].Name = "Day";
dataGridView.Columns[6].Name = "Year";
dataGridView.Columns[7].Name = "Delete";
AddCheckBoxForDataGridView(dataGridView, "Delete");
Thank you very much for your time.
Sincerely,
Bosco