Anthony Clarke

Anthony Clarke

  • NA
  • 127
  • 0

Populate whole datagridview column with date

Dec 8 2010 11:00 AM

Hi,
First of all, ill paste my bit of code and give an explanation of what im trying to accomplish and hope that you can help.
 
ETLSDataContext CT = new ETLSDataContext();
var t = from f in CT.Dates
select new
{
f.Date1
};

dataGridView1.DataSource = t;
dataGridView1.Columns.Add(
"D", "DateNow");
dataGridView1.Columns.Add(
"E", "DateDifference");
 
I have a SQL table with just Date1 in and use linq to pull it up
and the code i supplied shows me adding 2 other columns which are datenow and datedifference.
I need it so whenever the program loads it automatically populates the datagridview column "Datenow" with todays date and from there do some kind of a datediff query like
select datediff(Day, date1, datenow) as datedifference
I've been trying to do this all day and cannot come up with a solution and figured id ask the brain boxes.
 
Thanks for your time and patience.
Anthony

Answers (4)