Zdravím, mám jeden dotaz, jelikož na komponentu LV nejde použít wizard jako na DGW, chtěl bych se zeptat, jak postupovat při vypisování jednotlivých řádku z DataTable, viz kód:
Hello, i have got one questions, because with ListView component i cannot use the Wizard, i would like to ask, how to writeout all rows stored in database, resp.DataTable into List View component.
See code:
Thanks for any advice and sorry for my English..
// Load Data from the DataSet into the ListView
SqlConnection conn = new SqlConnection(@"
server = .\SQLEXPRESS;
integrated security = true;
database = Phone_directory");
conn.Open();
string sqlIns = @"SELECT * FROM tbl_phonebook";
//create query
SqlCommand cmdQry = new SqlCommand(sqlIns, conn);
SqlDataAdapter da = new SqlDataAdapter(cmdQry);
DataSet ds = new DataSet();
da.Fill(ds, "tbl_phonebook");
// Get the table from the data set
DataTable dtable = ds.Tables["tbl_phonebook"];
// Clear the ListView control
listViewUsers.Items.Clear();
// Add a column with width 20 and left alignment.
listViewUsers.Columns.Add("mobile_phone", 100, HorizontalAlignment.Left);
listViewUsers.Columns.Add("name", 100, HorizontalAlignment.Left);
// Display items in the ListView control
foreach (DataRow row in dtable.Rows)
{
[B] WHAT TYPE HERE? [/B]
}