This line DT.Rows.Add(DT);
should be written as, DT.Rows.Add(DR); Obviously you should add a DataRow object in DataRow collection On Fri, Mar 12, 2010 at 3:45 PM, Greg Hile <[email protected]> wrote: > I have Windowws Application and am using a Datagridview bound to a > DataTable. > > > > DataTable DT = new DataTable("Results"); > > DataRow DR; > > > > DataColumn Column1 = new DataColumn("First Column", Type.GetType( > "System.String")); > > DataColumn Column2 = new DataColumn("Second Column", Type > .GetType("System.String")); > > > > DT.Columns.Add(Column1); > > DT.Columns.Add(Column2); > > > > DR = DT.NewRow(); > > DR["First Column"] = "This is Column 1"; > > DR["Second Column"] = "This is Column 2"; > > > > DT.Rows.Add(DT); > > > > dataGridViewResults.DataSource = DT; > > > > > > But when I run this code I just get the word Results in the first table > cell. > > > > Can anyone tell me what I am doing wrong? > > > > Many thanks, > > Greg > > > > >
