1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
/// <summary>
/// Property to manage data
/// </summary>
private DataTable _sampleData
{
get
{
DataTable dt = (DataTable)Session["TestData"];
if (dt == null)
{
// Create a DataTable and save it to session
dt = new DataTable();
dt.Columns.Add(new DataColumn("Id", typeof(int)));
dt.Columns.Add(new DataColumn("Description", typeof(string)));
dt.Columns.Add(new DataColumn("AssignedTo", typeof(string)));
dt.Columns.Add(new DataColumn("Status", typeof(string)));
dt.Columns.Add(new DataColumn("Tick", typeof(string)));
dt.Rows.Add(new object[] { 1, "Create a new project", "Declan", "Complete", true });
dt.Rows.Add(new object[] { 2, "Build a demo applcation", "Olive", "In Progress", false });
dt.Rows.Add(new object[] { 3, "Test the demo applcation", "Peter", "Pending", true });
dt.Rows.Add(new object[] { 4, "Deploy the demo applcation", "Andy", "Pending", false });
dt.Rows.Add(new object[] { 5, "Support the demo applcation", "", "Pending", true });
// Add the id column as a primary key
DataColumn[] keys = new DataColumn[1];
keys[0] = dt.Columns["id"];
dt.PrimaryKey = keys;
_sampleData = dt;
}
return dt;
}
set
{
Session["TestData"] = value;
}
} |
Partager