void getData()
{
//init sqlconnection
#region
//SqlConnectionStringBuilder connbuilder = new SqlConnectionStringBuilder();
//connbuilder.DataSource = "(local)";
//connbuilder.IntegratedSecurity = true;
//connbuilder.InitialCatalog = "AdventureWorks";
////start to make sql query
//SqlConnection conn = new SqlConnection(connbuilder.ConnectionString);
//sda = new SqlDataAdapter("select ContactID,FirstName,LastName,EmailAddress from personcontact where ContactID<=100;", conn);
//SqlCommandBuilder commbuilder = new SqlCommandBuilder(sda);
//sda.UpdateCommand = commbuilder.GetUpdateCommand();
//dt = new DataTable();
//sda.AcceptChangesDuringUpdate = true;
//sda.Fill(dt);
#endregion
DataTable dt = GetTempData();
listView1.ItemsSource = dt.DefaultView;
}
private DataTable GetTempData()
{
DataTable dt = new DataTable();
DataColumn dc1 = new DataColumn();
dc1.ColumnName = "ContactID";
dc1.DataType = typeof(string);
DataColumn dc2 = new DataColumn();
dc2.ColumnName = "FirstName";
dc2.DataType = typeof(string);
DataColumn dc3 = new DataColumn();
dc3.ColumnName = "LastName";
dc3.DataType = typeof(string);
DataColumn dc4 = new DataColumn();
dc4.ColumnName = "EmailAddress";
dc4.DataType = typeof(string);
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
dt.Columns.Add(dc4);
DataRow dr1 = dt.NewRow();
dr1[0] = "1";
dr1[1] = "Philippines";
dr1[2] = "111";
dr1[3] = "111";
DataRow dr2 = dt.NewRow();
dr2[0] = "2";
dr2[1] = "Singapore";
dr2[2] = "222";
dr1[3] = "111";
DataRow dr3 = dt.NewRow();
dr3[0] = "3";
dr3[1] = "Philippines";
dr3[2] = "333";
dr1[3] = "111";
DataRow dr4 = dt.NewRow();
dr4[0] = "4";
dr4[1] = "Singapore";
dr4[2] = "444";
dr1[3] = "111";
dt.Rows.Add(dr1);
dt.Rows.Add(dr2);
dt.Rows.Add(dr3);
dt.Rows.Add(dr4);
return dt;
}D