Nezavolal.
Přidal jsem tedy referenci na system.web.dll a namespace System.Web.UI
Nahradil jsem
dgvVlastnostiVozidel.DataMember = "Vozidla";
tímto:
dgvVlastnostiVozidel.DataBind();
Výsledkem je hláška:
Error 1 'System.Windows.Forms.DataGridView' does not contain a definition for 'DataBind' and no extension method 'DataBind' accepting a first argument of type 'System.Windows.Forms.DataGridView' could be found (are you missing a using directive or an assembly reference?)
Ukázku použití DataBind jsem našel na:
http://www.okoun.cz/…ovani_v_c%23?…
--------------------------------------------------------------
Nejjednodussi pomoci DataBind - tady ukazka:
/dgKeywords je id datagridu/
private void LoadData()
{
string tblKey = ConfigurationSettings.AppSettings["tblKeywords"];
string tblPages = ConfigurationSettings.AppSettings["tblPages"];
// --------------
SqlConnection cn = new SqlConnection(ConfigurationSettings.AppSettings["dbConnectString"]);
cn.Open();
SqlCommand cmd = new SqlCommand("select * from " + tblKey + " order by klic", cn);
SqlDataReader sr = cmd.ExecuteReader();
dgKeywords.DataSource = sr;
dgKeywords.DataBind();
cmd.Dispose();
cn.Close();
}