Thursday

create datatable on the fly

// here is procedure for creating table on the fly
   
private DataTable CreateTable()
{
DataTable table = new DataTable("Report");
Type str = System.Type.GetType("System.String");
table.Columns.Add("chk1", System.Type.GetType("System.Boolean"));
table.Columns.Add("From", str);
table.Columns.Add("To",str);
table.Columns.Add("Hours", 0.0.GetType());
table.Columns.Add("Desc", str);
return table;
}

// below is procedure for filling table with data
private void ProcessReport()
{
xreport = XDocument.Load(ReportFile.Text);
var header = (from head in xreport.Elements("Journal").Elements("Header")
select head).First();

Rate.Text= header.Attribute("Rate").Value;

var entries = from entri in xreport.Elements("Journal").Elements("Entry")
select entri;
DataTable dataTable = CreateTable();
foreach (var element in entries)
{
DataRow dr = dataTable.NewRow();
dr["From"] = element.Attribute("StartTimeStamp").Value;
dr["To"] = element.Attribute("EndTimeStamp").Value;
dataTable.Rows.Add(dr);
}
Grid.DataSource = dataTable;
}

more...

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...