Пример #1
0
        public void loadData(string part)
        {
            partslist.Clear();


            SqlCommand com = new SqlCommand("select * from Products where type='" + part + "'", con);

            con.Open();
            SqlDataReader reader = com.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Product newproduct = new Product();
                    newproduct.id           = (Int32)reader["productid"];
                    newproduct.name         = reader["name"].ToString();
                    newproduct.imgurl       = reader["imgurl"].ToString();
                    newproduct.type         = reader["type"].ToString();
                    newproduct.defaultprice = (float)reader.GetDouble(4);
                    partslist.Add(newproduct);
                }
            }
            PartsGridView.DataSource = partslist;
            PartsGridView.DataBind();
            con.Close();
        }