I have an empty unbound gridview in my aspx web form. In the code behind I want to add three rows of data to three columna (ColA, ColB, ColC) in a 3x3 "table".
I want to add it row by row, and tried this:
DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add(new DataColumn("ColA", typeof(string)));
dt.Columns.Add(new DataColumn("ColB", typeof(string)));
dt.Columns.Add(new DataColumn("ColC", typeof(string)));
dr = dt.NewRow();
dr["ColA"] = "1";
dr["ColB"] = "2";
dr["ColC"] = "3";
dt.Rows.Add(dr);
dr["ColA"] = "4";
dr["ColB"] = "5";
dr["ColC"] = "6";
dt.Rows.Add(dr);
dr[" ...
Go to the complete details ...