Hello All, I am new to data access and
i have got the problem to display the data into the page by binding the gridview with sqlConnection, sqlCommand and sqlDataReader objects. The actually code is written as:
protectedvoid Page_Load(object sender,EventArgs e){
if (!Page.IsPostBack){
SqlConnection myConnection;SqlCommand myCommand;
SqlDataReader myReader;myConnection =newSqlConnection();
myConnection.ConnectionString =ConfigurationManager.ConnectionStrings["LatteConnectionString"].ConnectionString;myCommand =newSqlCommand();
myCommand.CommandText ="select * from AntiVirusVendors";myCommand.CommandType =CommandType.Text;myCommand.Connection = myConnection;
myCommand.Connection.Open();
myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);GridView1.DataSource = myReader;
GridView1.DataBind();
myCommand.Dispose();
myConnection.Dispose();
}
}
and the GridView in html is listed as:
<div>
<asp:GridViewID="GridView1"runat="server">
</asp:GridView>
</div>
So the problem is --> there is nothing shown in the page, no errors no anything... just the empty page.
Any ideas would be appreciated. Thanks in advance!
Joe
sorry, the problem has been solved.
No comments:
Post a Comment