protected void Page_Load(object sender, EventArgs e) { String query = "SELECT * from [dbo].[Posts] order by PostedDate"; SqlCommand command = new SqlCommand(query, conn); conn.Open(); SqlDataAdapter sda = new SqlDataAdapter(command); DataTable dt = new DataTable(); sda.Fill(dt); RepBlogDetails.DataSource = dt; RepBlogDetails.DataBind(); conn.Close(); }
protected void Page_Load(object sender, EventArgs e) { string mainconn = ConfigurationManager.ConnectionStrings["Myconnection"].ConnectionString; SqlConnection sqlconn = new SqlConnection(mainconn); string sqlquery = "select * from [dbo].[blog] where Bcategory='Movies'"; sqlconn.Open(); SqlCommand sqlcomm = new SqlCommand(sqlquery, sqlconn); SqlDataAdapter sda = new SqlDataAdapter(sqlcomm); DataTable dt = new DataTable(); sda.Fill(dt); RepBlogDetails.DataSource = dt; RepBlogDetails.DataBind(); sqlconn.Close(); }