Hi I want to get the gridview in pageload event without having a button,I have one dropdownlist if i select one value in dropdownlist
the details should be displayed in gridview in pageload event.
Here is my code...am not getting it.... Any help would be appreciated....
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConsString"].ConnectionString);
if (DDLSelectReport.SelectedValue == "Newly Purchased Book")
{
string sql = "select AccessionNo,ISBN,BookTitle,BookAuthor,ReceivedDate,Category,RackNo from LibManAddBook";
SqlCommand cmd = new SqlCommand(sql, con);
con.Open();
GridView1.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection);
GridView1.DataBind();
}
if (DDLSelectReport.SelectedValue == "Newly Purchased CD")
{
string sql1 = "select AccessionNo,CDTitle,CDAuthor,ReceivedDate,Category,RackNo from LibManAddCD1";
SqlCommand cmd = new SqlCommand(sql1, con);
con.Open();
GridView2.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection);
GridView2.DataBind();
}
}