Exemple #1
0
 private void LoadProducts(string categoryId)
 {
     try
     {
         DataView view = (Cache["Products"] as DataTable).DefaultView;
         view.RowFilter             = "categoryId=" + "'" + categoryId + "'";
         ProductDataList.DataSource = view;
         ProductDataList.DataBind();
     }
     catch (Exception ex)
     {
         ShowMessage(ex.Message, MessageInfo.Error);
     }
 }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //open the connection to the database
            SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["dbcon"].ToString());

            con.Open();
            //load up the sql adapter with the query to select from products
            SqlDataAdapter theSqlDataAdapter = new SqlDataAdapter("Select * from webuser.products", con);
            //create a new datatable
            DataTable theDataTable = new DataTable();

            theSqlDataAdapter.Fill(theDataTable);

            // listView.DataSource = theDataTable;
            // listView.DataBind();
            ProductDataList.DataSource = theDataTable;
            ProductDataList.DataBind();
        }