protected void Page_Load(object sender, EventArgs e) { /* * String sqlStatement = "select Id AS 'Company Order', CompanyName AS 'Company Name', HttpAddress AS 'URL', "; * sqlStatement += "NumberOfUser AS 'Number Of User' , CompanyValue AS 'Company Value (million dollars)', "; * sqlStatement += "CONVERT(VARCHAR(10), LaunchedDate, 103) AS 'Launched Date (DD/MM/YYYY)' from Companies "; * sqlStatement += "order by Id"; * * loadGridView(sqlStatement); */ CompaniesView.DataSource = null; CompaniesView.DataBind(); }
protected void loadGridView(String sqlStatement) { SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\SocialNetworks.mdf;Integrated Security=True"); SqlCommand cmd = new SqlCommand(sqlStatement, con); con.Open(); SqlDataReader wan = cmd.ExecuteReader(); CompaniesView.DataSource = wan; CompaniesView.DataBind(); con.Close(); }