Ejemplo n.º 1
0
        private System.Data.DataTable CreateDataTable()
        {
            var  table   = new CustomDataTable();
            bool isFirst = true;

            // without Linq
            for (int i = 0; i < students.Count; i++)
            {
                var student = students[i];
                if (isFirst)
                {
                    table.Columns.Add(FIRST_NAME);
                    table.Columns.Add(LAST_NAME);
                    table.Columns.Add(NUMBER);
                    isFirst = false;
                }

                var dataRow = (CustomDataRow)table.NewRow();
                dataRow.ItemArray = new string[] { student.FirstName, student.LastName, student.Number.ToString() };
                dataRow.Tag       = student;

                table.Rows.Add(dataRow);
            }

            return(table);
        }
Ejemplo n.º 2
0
        private System.Data.DataTable CreateDataTable()
        {
            var  table   = new CustomDataTable();
            bool isFirst = true;

            // without Linq
            for (int i = 0; i < students.Count; i++)
            {
                var student = students[i];
                if (isFirst)
                {
                    //table.Columns.Add(IN_CLASS, System.Type.GetType("System.Boolean"));
                    table.Columns.Add(IN_CLASS);
                    table.Columns.Add(FIRST_NAME);
                    table.Columns.Add(LAST_NAME);
                    table.Columns.Add(NUMBER);
                    isFirst = false;
                }

                //var dataRow = (CustomDataRow)table.NewRow();
                //dataRow.ItemArray = new string[] { student.FirstName, student.LastName, student.Number.ToString() };
                //dataRow.Tag = student;
                //table.Rows.Add(dataRow);

                var dataRow = (CustomDataRow)table.NewRow();

                //dataRow["InClass"] = "true"; bu otomatik olarak checkbox u dataya bakmadan işaretli getiriyor.
                dataRow["InClass"]   = student.InClass; // bu haliyle jsondakini doğru okuyor.
                dataRow["FirstName"] = student.FirstName;
                dataRow["LastName"]  = student.LastName;
                dataRow["Number"]    = student.Number;

                dataRow.Tag = student;

                table.Rows.Add(dataRow);
                table.AcceptChanges();
            }

            return(table);
        }